From 6e2635bc93481feae297c62c93f8c0da96648ea3 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 5 Apr 2016 07:32:06 +0200 Subject: [PATCH 1/6] Support wrapper-tag option for highlight command --- ly/cli/command.py | 1 + ly/cli/doc.py | 4 ++++ ly/cli/main.py | 3 ++- ly/cli/setvar.py | 6 ++++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ly/cli/command.py b/ly/cli/command.py index 3fb0ba49..2871b27a 100644 --- a/ly/cli/command.py +++ b/ly/cli/command.py @@ -230,6 +230,7 @@ def run(self, opts, cursor, output): w.number_lines = opts.number_lines w.title = cursor.document.filename w.encoding = opts.output_encoding or "utf-8" + w.wrapper_tag = opts.wrapper_tag doc = w.html(cursor) if self.output: diff --git a/ly/cli/doc.py b/ly/cli/doc.py index e63af30a..3215d97f 100644 --- a/ly/cli/doc.py +++ b/ly/cli/doc.py @@ -175,6 +175,10 @@ ``number-lines`` [``false``] whether to add line numbers when creating syntax-highlighted HTML. + ``wrapper-tag`` [``pre``] + which tag syntax highlighted HTML will be wrapped in. Possible values: + ``div``, ``pre``, ``id`` and ``code`` + These variables influence the output of information commands: ``with-filename`` diff --git a/ly/cli/main.py b/ly/cli/main.py index 627b8206..03b38e95 100644 --- a/ly/cli/main.py +++ b/ly/cli/main.py @@ -80,7 +80,8 @@ def __init__(self): self.inline_style = False self.stylesheet = None self.number_lines = False - + self.wrapper_tag = 'pre' + def set_variable(self, name, value): name = name.replace('-', '_') try: diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py index f677b5cc..d7da54df 100644 --- a/ly/cli/setvar.py +++ b/ly/cli/setvar.py @@ -130,4 +130,10 @@ def stylesheet(arg): def number_lines(arg): return _check_bool("number-lines", arg) +def wrapper_tag(arg): + if not arg in ['div', 'pre', 'code', 'id']: + raise ValueError("unknown wrapper tag: {tag}".format( + tag=arg)) + return arg + From ca666fa6847dcc6aa7e829737bf8aa9f14b6ad26 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 5 Apr 2016 09:13:39 +0200 Subject: [PATCH 2/6] Support wrapper-attribute option --- ly/cli/command.py | 1 + ly/cli/doc.py | 3 +++ ly/cli/main.py | 1 + ly/cli/setvar.py | 6 +++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ly/cli/command.py b/ly/cli/command.py index 2871b27a..d886439f 100644 --- a/ly/cli/command.py +++ b/ly/cli/command.py @@ -231,6 +231,7 @@ def run(self, opts, cursor, output): w.title = cursor.document.filename w.encoding = opts.output_encoding or "utf-8" w.wrapper_tag = opts.wrapper_tag + w.wrapper_attribute = opts.wrapper_attribute doc = w.html(cursor) if self.output: diff --git a/ly/cli/doc.py b/ly/cli/doc.py index 3215d97f..a81a5d41 100644 --- a/ly/cli/doc.py +++ b/ly/cli/doc.py @@ -179,6 +179,9 @@ which tag syntax highlighted HTML will be wrapped in. Possible values: ``div``, ``pre``, ``id`` and ``code`` + ``wrapper-attribute`` [``class``] + attribute used for the wrapper tag. Possible values: ``id`` and ``class``. + These variables influence the output of information commands: ``with-filename`` diff --git a/ly/cli/main.py b/ly/cli/main.py index 03b38e95..e6f5723d 100644 --- a/ly/cli/main.py +++ b/ly/cli/main.py @@ -81,6 +81,7 @@ def __init__(self): self.stylesheet = None self.number_lines = False self.wrapper_tag = 'pre' + self.wrapper_attribute = 'class' def set_variable(self, name, value): name = name.replace('-', '_') diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py index d7da54df..21dac6c9 100644 --- a/ly/cli/setvar.py +++ b/ly/cli/setvar.py @@ -136,4 +136,8 @@ def wrapper_tag(arg): tag=arg)) return arg - +def wrapper_attribute(arg): + if not arg in ['id', 'class']: + raise ValueError("wrapper attribute must be 'id' or 'class', found {attr}".format( + attr=arg)) + return arg From 514ca3f68bdcb0965381f7d5d8806aed70a2e5da Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 5 Apr 2016 09:19:07 +0200 Subject: [PATCH 3/6] Support document-id option --- ly/cli/command.py | 1 + ly/cli/doc.py | 6 ++++++ ly/cli/main.py | 1 + ly/cli/setvar.py | 3 +++ 4 files changed, 11 insertions(+) diff --git a/ly/cli/command.py b/ly/cli/command.py index d886439f..c2e69771 100644 --- a/ly/cli/command.py +++ b/ly/cli/command.py @@ -232,6 +232,7 @@ def run(self, opts, cursor, output): w.encoding = opts.output_encoding or "utf-8" w.wrapper_tag = opts.wrapper_tag w.wrapper_attribute = opts.wrapper_attribute + w.document_id = opts.document_id doc = w.html(cursor) if self.output: diff --git a/ly/cli/doc.py b/ly/cli/doc.py index a81a5d41..7e46446a 100644 --- a/ly/cli/doc.py +++ b/ly/cli/doc.py @@ -182,6 +182,12 @@ ``wrapper-attribute`` [``class``] attribute used for the wrapper tag. Possible values: ``id`` and ``class``. + ``document-id`` [``lilypond``] + name applied to the wrapper-attribute. + If the three last options use their default settings + the highlighted HTML elements are wrapped in an element + ``
``
+
 These variables influence the output of information commands:
 
   ``with-filename``
diff --git a/ly/cli/main.py b/ly/cli/main.py
index e6f5723d..197a1178 100644
--- a/ly/cli/main.py
+++ b/ly/cli/main.py
@@ -82,6 +82,7 @@ def __init__(self):
         self.number_lines = False
         self.wrapper_tag = 'pre'
         self.wrapper_attribute = 'class'
+        self.document_id = 'lilypond'
 
     def set_variable(self, name, value):
         name = name.replace('-', '_')
diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py
index 21dac6c9..1cea31c3 100644
--- a/ly/cli/setvar.py
+++ b/ly/cli/setvar.py
@@ -141,3 +141,6 @@ def wrapper_attribute(arg):
         raise ValueError("wrapper attribute must be 'id' or 'class', found {attr}".format(
             attr=arg))
     return arg
+    
+def document_id(arg):
+    return arg or None

From 7c3fb863488da64b772ca216311402dfb38e490e Mon Sep 17 00:00:00 2001
From: Urs Liska 
Date: Tue, 5 Apr 2016 09:22:37 +0200
Subject: [PATCH 4/6] Support linenumbers-id option

---
 ly/cli/command.py | 1 +
 ly/cli/doc.py     | 3 +++
 ly/cli/main.py    | 1 +
 ly/cli/setvar.py  | 3 +++
 4 files changed, 8 insertions(+)

diff --git a/ly/cli/command.py b/ly/cli/command.py
index c2e69771..3ed39f07 100644
--- a/ly/cli/command.py
+++ b/ly/cli/command.py
@@ -233,6 +233,7 @@ def run(self, opts, cursor, output):
         w.wrapper_tag = opts.wrapper_tag
         w.wrapper_attribute = opts.wrapper_attribute
         w.document_id = opts.document_id
+        w.linenumbers_id = opts.linenumbers_id
 
         doc = w.html(cursor)
         if self.output:
diff --git a/ly/cli/doc.py b/ly/cli/doc.py
index 7e46446a..6a779e80 100644
--- a/ly/cli/doc.py
+++ b/ly/cli/doc.py
@@ -188,6 +188,9 @@
         the highlighted HTML elements are wrapped in an element
         ``
``
 
+  ``linenumbers-id`` [``linenumbers``]
+        if linenumbers are exported this is the name used for the ```` elements
+
 These variables influence the output of information commands:
 
   ``with-filename``
diff --git a/ly/cli/main.py b/ly/cli/main.py
index 197a1178..a6cfc3ca 100644
--- a/ly/cli/main.py
+++ b/ly/cli/main.py
@@ -83,6 +83,7 @@ def __init__(self):
         self.wrapper_tag = 'pre'
         self.wrapper_attribute = 'class'
         self.document_id = 'lilypond'
+        self.linenumbers_id = 'linenumbers'
 
     def set_variable(self, name, value):
         name = name.replace('-', '_')
diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py
index 1cea31c3..30e9ebd7 100644
--- a/ly/cli/setvar.py
+++ b/ly/cli/setvar.py
@@ -144,3 +144,6 @@ def wrapper_attribute(arg):
     
 def document_id(arg):
     return arg or None
+
+def linenumbers_id(arg):
+    return arg or None

From bc4f67e366830b2c12aed6bf2997d7e63102f8c9 Mon Sep 17 00:00:00 2001
From: Urs Liska 
Date: Tue, 5 Apr 2016 09:28:41 +0200
Subject: [PATCH 5/6] Support full-html option

---
 ly/cli/command.py | 1 +
 ly/cli/doc.py     | 5 +++++
 ly/cli/main.py    | 1 +
 ly/cli/setvar.py  | 3 +++
 4 files changed, 10 insertions(+)

diff --git a/ly/cli/command.py b/ly/cli/command.py
index 3ed39f07..075b77ef 100644
--- a/ly/cli/command.py
+++ b/ly/cli/command.py
@@ -225,6 +225,7 @@ def run(self, opts, cursor, output):
         import ly.colorize
         w = ly.colorize.HtmlWriter()
 
+        w.full_html = opts.full_html
         w.inline_style = opts.inline_style
         w.stylesheet_ref = opts.stylesheet
         w.number_lines = opts.number_lines
diff --git a/ly/cli/doc.py b/ly/cli/doc.py
index 6a779e80..2fa52af2 100644
--- a/ly/cli/doc.py
+++ b/ly/cli/doc.py
@@ -163,6 +163,11 @@
   ``indent-width`` [2]
          how many spaces for each indent level (if not using tabs)
 
+  ``full-html`` [``True``]
+        if set to True a full document with syntax-highlighted HTML
+        will be exported, otherwise only the bare content wrapped in an
+        element configured by the ``wrapper-`` variables.        
+
   ``stylesheet``
          filename to reference as an external stylesheet for
          syntax-highlighted HTML. This filename is literally used
diff --git a/ly/cli/main.py b/ly/cli/main.py
index a6cfc3ca..82d52a3b 100644
--- a/ly/cli/main.py
+++ b/ly/cli/main.py
@@ -77,6 +77,7 @@ def __init__(self):
         self.indent_tabs = False
         self.tab_width = 8
         
+        self.full_html = True
         self.inline_style = False
         self.stylesheet = None
         self.number_lines = False
diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py
index 30e9ebd7..5533dc20 100644
--- a/ly/cli/setvar.py
+++ b/ly/cli/setvar.py
@@ -123,6 +123,9 @@ def inline_style(arg):
     return _check_bool("inline-style", arg)
 
 
+def full_html(arg):
+    return _check_bool("full_html", arg)
+
 def stylesheet(arg):
     return arg or None
 

From d1c6c23146cc589c5d76baa4f395a2f11653fd11 Mon Sep 17 00:00:00 2001
From: Urs Liska 
Date: Tue, 5 Apr 2016 09:29:08 +0200
Subject: [PATCH 6/6] clean-up: Add some separator lines

Adjust new code to existing file layout
---
 ly/cli/setvar.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ly/cli/setvar.py b/ly/cli/setvar.py
index 5533dc20..63d466dc 100644
--- a/ly/cli/setvar.py
+++ b/ly/cli/setvar.py
@@ -126,6 +126,7 @@ def inline_style(arg):
 def full_html(arg):
     return _check_bool("full_html", arg)
 
+
 def stylesheet(arg):
     return arg or None
 
@@ -133,20 +134,24 @@ def stylesheet(arg):
 def number_lines(arg):
     return _check_bool("number-lines", arg)
 
+
 def wrapper_tag(arg):
     if not arg in ['div', 'pre', 'code', 'id']:
         raise ValueError("unknown wrapper tag: {tag}".format(
             tag=arg))
     return arg
 
+
 def wrapper_attribute(arg):
     if not arg in ['id', 'class']:
         raise ValueError("wrapper attribute must be 'id' or 'class', found {attr}".format(
             attr=arg))
     return arg
+
     
 def document_id(arg):
     return arg or None
 
+
 def linenumbers_id(arg):
     return arg or None