Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
021a906
Initial HTML export
jefferyshivers Mar 6, 2017
6f1d9f3
add output html for example
jefferyshivers Mar 6, 2017
07d8e2e
WIP adds some special config options for html and css
jefferyshivers Mar 7, 2017
8ad731b
html and css example
jefferyshivers Mar 7, 2017
90e0eb9
implements format-location and removes default props to print (user m…
jefferyshivers Mar 7, 2017
609f89b
make export procedure / filenames configurable with options
jefferyshivers Mar 7, 2017
f17cdf9
make annotations a div with so named class again
jefferyshivers Mar 7, 2017
53121cc
Merge branch 'master' into export-html
jefferyshivers Mar 7, 2017
9a4ceb8
adds html-id prop check/addition for each annotation
jefferyshivers Mar 11, 2017
6cd604b
simplify div-open procedure, make code more legible
jefferyshivers Mar 11, 2017
e0eaf62
simplify procedure for getting html props
jefferyshivers Mar 11, 2017
118e897
adds setOption example for testing html props, removes comment
jefferyshivers Mar 11, 2017
7c6c636
seperate type class names vs type output labels
jefferyshivers Mar 11, 2017
b2c511f
remove option to rename type classes, it is an useless option right now
jefferyshivers Mar 11, 2017
96819a7
update readme to reflect html output
jefferyshivers Mar 11, 2017
9db4a68
add opt to print full doc or just annotations div
jefferyshivers Mar 12, 2017
9384bf7
remove html stuff
jefferyshivers Mar 12, 2017
dc73d39
add the word 'json' to paragraph
jefferyshivers Mar 12, 2017
169cbc3
add <html> and doctype as well
jefferyshivers Mar 12, 2017
dfd8df2
add utf-8 charset to html page
uliska Mar 12, 2017
83fb277
Use format instead of chained string-append
uliska Mar 12, 2017
6d48a1f
Fix indent of commit dfd8df20 (oops)
uliska Mar 12, 2017
871d6e7
adds a few more conenience fns for cleanliness; implements option to …
jefferyshivers Mar 13, 2017
e56f927
just remove deprecated conenience fn
jefferyshivers Mar 13, 2017
10444ed
adds initial ability to simply print prop labels (like 'Type: ') with…
jefferyshivers Mar 14, 2017
b7db871
Replace series' of println with single expressions
uliska Mar 14, 2017
35a7c7d
Remove "println" helper function
uliska Mar 14, 2017
590327f
Adapt indentation to Frescobaldi style
uliska Mar 14, 2017
39bba6e
Simpler implementation of nest-indent
uliska Mar 14, 2017
ea1cb51
Reduce redundant code in "div-open"
uliska Mar 14, 2017
9677c5f
rename nest-indent to indent
uliska Mar 14, 2017
eec17f2
adds explicit css naming options
jefferyshivers Mar 14, 2017
654b7cd
change equal to eq and just fix indentation
jefferyshivers Mar 14, 2017
c9b4745
WIP a css formatter for exported or header (generated, or default)
jefferyshivers Mar 15, 2017
98f4464
trivial, remove unnecessary let* asterisk
jefferyshivers Mar 15, 2017
6558709
prints formatted css to header (not totally clean yet, visually-speak…
jefferyshivers Mar 15, 2017
8371f0b
formats css prettier
jefferyshivers Mar 15, 2017
7f6deec
WIP filling in css formatting procedure 1 of 2
jefferyshivers Mar 15, 2017
a71c56b
oops this goes with previous commit
jefferyshivers Mar 15, 2017
2c17aa8
fix use-css functionality, now prints default or custom into header
jefferyshivers Mar 15, 2017
5b28f0d
applies optional 'annotations' div class/id if specified
jefferyshivers Mar 15, 2017
38448b1
updates example generated css
jefferyshivers Mar 15, 2017
da8ae30
outputs generated css file if option selected
jefferyshivers Mar 15, 2017
141fa37
adds comments
jefferyshivers Apr 11, 2017
05d5058
Merge branch 'master' into export-html
uliska Jul 10, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions annotate/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ annotations are printed* (see `scholarly/annotate/config.ily`). At the beginning
the music document, we can tell *scholarLY* which types of documents to export:

```lilypond
\setOption scholarly.annotate.export-targets #'(plaintext latex)
\setOption scholarly.annotate.export-targets #'(plaintext html latex)
```

Those output files will automatically format annotations to be further processed by the
relevant programs. Currently, *plaintext* and *latex* are available, while other types
relevant programs. Currently, *plaintext*, *latex* and *html* are available, while other types
are on the wishlist (such as *scheme* and *markdown*).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could add json to the list


## Basic Syntax
Expand Down
44 changes: 44 additions & 0 deletions annotate/config.ily
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,25 @@
\registerOption scholarly.colorize ##t




%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Filenames to Export
%%%%%%%%%%%%%%%%%%%%%%%%
% default is <project-name>.annotations.<ext>
\registerOption scholarly.annotate.export.filenames
% <ext> <file name>
#`((html . "index.html") ;; html
(latex . default) ;; latex
(scheme . default) ;; scheme
(plaintext . default) ;; plaintext
)






%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Handling of annotation types for plain text output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -111,6 +130,31 @@
(question . "Question:")
(todo . "TODO:"))



%%%%%%%%%%%%%%%%%
%%%% HTML options
%%%%%%%%%%%%%%%%%

% Annotation types for html text output
\registerOption scholarly.annotate.export.html.labels
#`((critical-remark . "Critical Remark")
(musical-issue . "Musical Issue")
(lilypond-issue . "Lilypond Issue>")
(question . "Question")
(todo . "TODO"))


% Which props to print to html
\registerOption scholarly.annotate.export.html.props
#`(type grob-location grob-type message)

% Which stylesheet to link in html (just a proof of concept at the moment)
\registerOption scholarly.annotate.export.html.css
#"annotate-styles.css"


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need the option

\registerOption scholarly.annotate.export.html.full-document ##t

here. Of course it also has to be processed somewhere ...


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Handling of annotation types for LaTeX output
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down
138 changes: 138 additions & 0 deletions annotate/export-html.ily
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% This file is part of ScholarLY, %
% ========= %
% a toolkit library for scholarly work with GNU LilyPond and LaTeX, %
% belonging to openLilyLib (https://github.com/openlilylib/openlilylib %
% ----------- %
% %
% ScholarLY is free software: you can redistribute it and/or modify %
% it under the terms of the GNU General Public License as published by %
% the Free Software Foundation, either version 3 of the License, or %
% (at your option) any later version. %
% %
% ScholarLY is distributed in the hope that it will be useful, %
% but WITHOUT ANY WARRANTY; without even the implied warranty of %
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %
% GNU Lesser General Public License for more details. %
% %
% You should have received a copy of the GNU General Public License %
% along with ScholarLY. If not, see <http://www.gnu.org/licenses/>. %
% %
% ScholarLY is maintained by Urs Liska, [email protected] %
% Copyright Urs Liska, 2015-17 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Export annotations to html file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define (nest-indent inpt num)
(let* ((indentation ""))
(do ((i 0 (1+ i)))
((= i num))
(set! indentation (string-append indentation " ")))
(string-append indentation inpt)))


% convenience functions
#(define (stringify-html-tag tag)
(format "\"~a\"" tag))
#(define (delimit-html-tags tags)
(format "<div ~a>" tags))

% open div with unique tags
#(define (div-open ann-or-string nest-level)
;; if class = string, don't check for an id. otherwise it
;; is an ann props list, so check for an id and apply if necessary
(if (string? ann-or-string)
(let* ((class (string-append "class=" (stringify-html-tag ann-or-string)))
(div-tag (delimit-html-tags class))
(div-begin (nest-indent div-tag nest-level)))
(append-to-output-stringlist div-begin))
(let* ((ann ann-or-string)
(class (string-append "class=" (stringify-html-tag "annotation")))
(id (if (assq-ref ann 'html-id)
(string-append " id=" (stringify-html-tag (assoc-ref ann 'html-id)))
""))
(div-tags (delimit-html-tags (string-append class id)))
(div-begin (nest-indent div-tags nest-level)))
(append-to-output-stringlist div-begin))))

% close any div
#(define (div-close nest-level)
(append-to-output-stringlist (nest-indent "</div>" nest-level)))

% get all the props we want exported from the option
#(define (html-process-props ann)
(let ((props (getOption `(scholarly annotate export html props))))
(for-each
(lambda (prop)
(let* ((val (cond ((equal? prop 'grob-location)
(format-location ann))
((equal? prop 'type)
(getChildOption
`(scholarly annotate export html labels)
(assq-ref ann 'type)))
(else (assq-ref ann prop)))))
(begin
(if (symbol? val)
(set! val (symbol->string val)))
(div-open (symbol->string prop) 3)
(append-to-output-stringlist
(nest-indent val 4))
(div-close 3))))
props)))



\register-export-routine html
#(lambda ()

(let ((println append-to-output-stringlist))

(println "<head>")
(println (string-append
" <link rel=\"stylesheet\" type=\"text/css\" href=\""
(string-append (getOption `(scholarly annotate export html css))
"\">")))
(println "</head>")
(println " ")

(println "<body>")
(println " ")

;; wrap everything in the annotations div. this is sort of redundant, but
;; could be useful if projects have multiple bookparts with annotation lists.
(div-open "annotations" 0)
(println " ")

(for-each
(lambda (ann)

;; wrap each annotation in the common annotation class
;; add div ID tag if available
(div-open ann 1)

;; type as a class - maybe we want different types to have some different styles
(div-open (symbol->string (assq-ref ann 'type)) 2)

;; add the rest of the props to output
(html-process-props ann) ;; nest-indents x 3

(div-close 2)

(div-close 1)
(println " "))

annotations)

;; close ann list div
(div-close 0)
(println " ")

(println "</body>")

;; write to output file
(write-output-file 'html)))
3 changes: 1 addition & 2 deletions annotate/export-latex.ily
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,4 @@
annotations)

;; write to output file
(write-output-file "inp"))

(write-output-file 'latex))
3 changes: 1 addition & 2 deletions annotate/export-plaintext.ily
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,4 @@
annotations)

;; write to output file
(write-output-file "log"))

(write-output-file 'plaintext))
19 changes: 12 additions & 7 deletions annotate/export.ily
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,22 @@ setAnnotationOutputBasename =

% Take the stringlist 'annotate-export-stringlist
% and write it out to a file
#(define (write-output-file ext)
#(define (write-output-file type)
;
; TODO
; remove "messages" here and directly use the global object
;
; TODO
; Make the file name configurable and let it respect the target format
;
(let* ((logfile (format "~a.annotations.~a" annotation-out-basename ext)))
(let* ((default-exts '((html . "html")
(latex . "inp")
(scheme . "scm")
(plaintext . "log")))
(logfile (if (equal? (getChildOption
'(scholarly annotate export filenames) type)
'default)
(format "~a.annotations.~a" annotation-out-basename
(assoc-ref default-exts type))
(getChildOption
'(scholarly annotate export filenames) type))))
(ly:message "writing '~a' ..." logfile)
(with-output-to-file logfile
(lambda ()
Expand Down Expand Up @@ -140,5 +147,3 @@ setAnnotationOutputBasename =
ly:message)
(ly:message "")))
annotations))


1 change: 1 addition & 0 deletions annotate/module.ily
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
\include "export.ily"
\include "export-latex.ily"
\include "export-plaintext.ily"
\include "export-html.ily"
\include "engraver.ily"

% Include `editorial-functions` module
Expand Down
16 changes: 16 additions & 0 deletions usage-examples/annotate-styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

html,
body {
background: gray;
margin: 0.5em;
}

annotations {
width: 100%;
height: 100%;
}

.annotation {
margin: 1em;
background: lightgray;
}
6 changes: 5 additions & 1 deletion usage-examples/annotate.ly
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@

\markup \vspace #1

\setOption scholarly.annotate.export-targets #'(plaintext latex)
\setOption scholarly.annotate.export-targets #'(plaintext latex html)

\setOption scholarly.annotate.export.html.props
#`(type grob-type message)

music = \relative c'{
c4 d e
\criticalRemark \with {
Expand All @@ -32,6 +35,7 @@ music = \relative c'{
{ \voiceOne
\criticalRemark \with {
message = "An annotation for the top voice."
html-id = "my-unique-id"
}
NoteHead
cis d
Expand Down
Loading