Merge pull request #114 from donaldh/noweb-redux
Honour org :noweb strip-export parameter when writing HTML
This commit is contained in:
commit
f7c2b120f7
6 changed files with 21 additions and 2 deletions
|
@ -241,7 +241,7 @@ func (d *Document) parseOne(i int, stop stopFn) (consumed int, node Node) {
|
||||||
if consumed != 0 {
|
if consumed != 0 {
|
||||||
return consumed, node
|
return consumed, node
|
||||||
}
|
}
|
||||||
d.Log.Printf("Could not parse token %#v: Falling back to treating it as plain text.", d.tokens[i])
|
d.Log.Printf("Could not parse token %#v in file %s: Falling back to treating it as plain text.", d.tokens[i], d.Path)
|
||||||
m := plainTextRegexp.FindStringSubmatch(d.tokens[i].matches[0])
|
m := plainTextRegexp.FindStringSubmatch(d.tokens[i].matches[0])
|
||||||
d.tokens[i] = token{"text", len(m[1]), m[2], m}
|
d.tokens[i] = token{"text", len(m[1]), m[2], m}
|
||||||
return d.parseOne(i, stop)
|
return d.parseOne(i, stop)
|
||||||
|
|
|
@ -152,6 +152,10 @@ func (w *HTMLWriter) WriteBlock(b Block) {
|
||||||
if params[":exports"] == "results" || params[":exports"] == "none" {
|
if params[":exports"] == "results" || params[":exports"] == "none" {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
if params[":noweb"] == "strip-export" {
|
||||||
|
stripNoweb := regexp.MustCompile(`<<[^>]+>>`)
|
||||||
|
content = stripNoweb.ReplaceAllString(content, "")
|
||||||
|
}
|
||||||
lang := "text"
|
lang := "text"
|
||||||
if len(b.Parameters) >= 1 {
|
if len(b.Parameters) >= 1 {
|
||||||
lang = strings.ToLower(b.Parameters[0])
|
lang = strings.ToLower(b.Parameters[0])
|
||||||
|
|
|
@ -45,7 +45,7 @@ func testWriter(t *testing.T, newWriter func() Writer, ext string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%s\n got error: %s", path, err)
|
t.Fatalf("%s\n got error: %s", path, err)
|
||||||
} else if actual != expected {
|
} else if actual != expected {
|
||||||
t.Fatalf("%s:\n%s'", path, "")
|
t.Fatalf("%s:\n%s'", path, diff(actual, expected))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
7
org/testdata/blocks.html
vendored
7
org/testdata/blocks.html
vendored
|
@ -195,3 +195,10 @@ Snow covers Emacs</p>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
<div class="src src-raku">
|
||||||
|
<div class="highlight">
|
||||||
|
<pre>
|
||||||
|
describe <a b c>;
|
||||||
|
</pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
4
org/testdata/blocks.org
vendored
4
org/testdata/blocks.org
vendored
|
@ -176,3 +176,7 @@ this unindented line is outside of the list item
|
||||||
|
|
||||||
---AlexSchroeder
|
---AlexSchroeder
|
||||||
#+END_VERSE
|
#+END_VERSE
|
||||||
|
|
||||||
|
#+BEGIN_SRC raku :results output :noweb strip-export :exports both
|
||||||
|
<<defn>>describe <a b c>;
|
||||||
|
#+END_SRC
|
||||||
|
|
4
org/testdata/blocks.pretty_org
vendored
4
org/testdata/blocks.pretty_org
vendored
|
@ -176,3 +176,7 @@ this unindented line is outside of the list item
|
||||||
|
|
||||||
---AlexSchroeder
|
---AlexSchroeder
|
||||||
#+END_VERSE
|
#+END_VERSE
|
||||||
|
|
||||||
|
#+BEGIN_SRC raku :results output :noweb strip-export :exports both
|
||||||
|
<<defn>>describe <a b c>;
|
||||||
|
#+END_SRC
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue