-
Notifications
You must be signed in to change notification settings - Fork 6
Export html #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jefferyshivers
wants to merge
45
commits into
master
Choose a base branch
from
export-html
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Export html #52
Changes from 15 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
021a906
Initial HTML export
jefferyshivers 6f1d9f3
add output html for example
jefferyshivers 07d8e2e
WIP adds some special config options for html and css
jefferyshivers 8ad731b
html and css example
jefferyshivers 90e0eb9
implements format-location and removes default props to print (user m…
jefferyshivers 609f89b
make export procedure / filenames configurable with options
jefferyshivers f17cdf9
make annotations a div with so named class again
jefferyshivers 53121cc
Merge branch 'master' into export-html
jefferyshivers 9a4ceb8
adds html-id prop check/addition for each annotation
jefferyshivers 6cd604b
simplify div-open procedure, make code more legible
jefferyshivers e0eaf62
simplify procedure for getting html props
jefferyshivers 118e897
adds setOption example for testing html props, removes comment
jefferyshivers 7c6c636
seperate type class names vs type output labels
jefferyshivers b2c511f
remove option to rename type classes, it is an useless option right now
jefferyshivers 96819a7
update readme to reflect html output
jefferyshivers 9db4a68
add opt to print full doc or just annotations div
jefferyshivers 9384bf7
remove html stuff
jefferyshivers dc73d39
add the word 'json' to paragraph
jefferyshivers 169cbc3
add <html> and doctype as well
jefferyshivers dfd8df2
add utf-8 charset to html page
uliska 83fb277
Use format instead of chained string-append
uliska 6d48a1f
Fix indent of commit dfd8df20 (oops)
uliska 871d6e7
adds a few more conenience fns for cleanliness; implements option to …
jefferyshivers e56f927
just remove deprecated conenience fn
jefferyshivers 10444ed
adds initial ability to simply print prop labels (like 'Type: ') with…
jefferyshivers b7db871
Replace series' of println with single expressions
uliska 35a7c7d
Remove "println" helper function
uliska 590327f
Adapt indentation to Frescobaldi style
uliska 39bba6e
Simpler implementation of nest-indent
uliska ea1cb51
Reduce redundant code in "div-open"
uliska 9677c5f
rename nest-indent to indent
uliska eec17f2
adds explicit css naming options
jefferyshivers 654b7cd
change equal to eq and just fix indentation
jefferyshivers c9b4745
WIP a css formatter for exported or header (generated, or default)
jefferyshivers 98f4464
trivial, remove unnecessary let* asterisk
jefferyshivers 6558709
prints formatted css to header (not totally clean yet, visually-speak…
jefferyshivers 8371f0b
formats css prettier
jefferyshivers 7f6deec
WIP filling in css formatting procedure 1 of 2
jefferyshivers a71c56b
oops this goes with previous commit
jefferyshivers 2c17aa8
fix use-css functionality, now prints default or custom into header
jefferyshivers 5b28f0d
applies optional 'annotations' div class/id if specified
jefferyshivers 38448b1
updates example generated css
jefferyshivers da8ae30
outputs generated css file if option selected
jefferyshivers 141fa37
adds comments
jefferyshivers 05d5058
Merge branch 'master' into export-html
uliska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
|
@@ -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" | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ##there. Of course it also has to be processed somewhere ... |
||
|
|
||
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
| %%%% Handling of annotation types for LaTeX output | ||
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,5 +218,4 @@ | |
| annotations) | ||
|
|
||
| ;; write to output file | ||
| (write-output-file "inp")) | ||
|
|
||
| (write-output-file 'latex)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,5 +73,4 @@ | |
| annotations) | ||
|
|
||
| ;; write to output file | ||
| (write-output-file "log")) | ||
|
|
||
| (write-output-file 'plaintext)) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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