Misc cleanup: SETUP_FILE -> SETUPFILE, empty example lines, ...
This commit is contained in:
parent
d1054063cf
commit
bc9c496f97
11 changed files with 17 additions and 15 deletions
|
@ -8,11 +8,11 @@ type Example struct {
|
|||
Children []Node
|
||||
}
|
||||
|
||||
var exampleLineRegexp = regexp.MustCompile(`^(\s*): (.*)`)
|
||||
var exampleLineRegexp = regexp.MustCompile(`^(\s*):(\s(.*)|\s*$)`)
|
||||
|
||||
func lexExample(line string) (token, bool) {
|
||||
if m := exampleLineRegexp.FindStringSubmatch(line); m != nil {
|
||||
return token{"example", len(m[1]), m[2], m}, true
|
||||
return token{"example", len(m[1]), m[3], m}, true
|
||||
}
|
||||
return nilToken, false
|
||||
}
|
||||
|
|
|
@ -118,13 +118,10 @@ func (d *Document) parseExplicitLineBreak(input string, start int) (int, Node) {
|
|||
if start == 0 || input[start-1] == '\n' || start+1 >= len(input) || input[start+1] != '\\' {
|
||||
return 0, nil
|
||||
}
|
||||
for i := start + 2; ; i++ {
|
||||
if i == len(input)-1 || input[i] == '\n' {
|
||||
for i := start + 2; unicode.IsSpace(rune(input[i])); i++ {
|
||||
if i >= len(input) || input[i] == '\n' {
|
||||
return i + 1 - start, ExplicitLineBreak{}
|
||||
}
|
||||
if !unicode.IsSpace(rune(input[i])) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
@ -202,7 +199,7 @@ func (d *Document) parseAutoLink(input string, start int) (int, int, Node) {
|
|||
|
||||
func (d *Document) parseRegularLink(input string, start int) (int, Node) {
|
||||
input = input[start:]
|
||||
if len(input) < 3 || input[1] != '[' || input[2] == '[' {
|
||||
if len(input) < 3 || input[:2] != "[[" || input[2] == '[' {
|
||||
return 0, nil
|
||||
}
|
||||
end := strings.Index(input, "]]")
|
||||
|
|
|
@ -52,7 +52,7 @@ func (d *Document) parseComment(i int, stop stopFn) (int, Node) {
|
|||
func (d *Document) parseKeyword(i int, stop stopFn) (int, Node) {
|
||||
k := parseKeyword(d.tokens[i])
|
||||
switch k.Key {
|
||||
case "SETUP_FILE":
|
||||
case "SETUPFILE":
|
||||
return d.loadSetupFile(k)
|
||||
case "INCLUDE":
|
||||
return d.newInclude(k)
|
||||
|
|
|
@ -191,8 +191,10 @@ func (w *OrgWriter) writeParagraph(p Paragraph) {
|
|||
|
||||
func (w *OrgWriter) writeExample(e Example) {
|
||||
for _, n := range e.Children {
|
||||
w.WriteString(w.indent + ":" + " ")
|
||||
w.writeNodes(n)
|
||||
w.WriteString(w.indent + ":")
|
||||
if content := w.nodesAsString(n); content != "" {
|
||||
w.WriteString(" " + content)
|
||||
}
|
||||
w.WriteString("\n")
|
||||
}
|
||||
}
|
||||
|
|
1
org/testdata/blocks.html
vendored
1
org/testdata/blocks.html
vendored
|
@ -35,6 +35,7 @@ src, example & export blocks treat their content as raw text
|
|||
<pre class="example">
|
||||
examples like this
|
||||
are also supported
|
||||
|
||||
note that /inline/ *markup* ignored
|
||||
</pre>
|
||||
<blockquote>
|
||||
|
|
1
org/testdata/blocks.org
vendored
1
org/testdata/blocks.org
vendored
|
@ -29,6 +29,7 @@ src, example & export blocks treat their content as raw text
|
|||
|
||||
: examples like this
|
||||
: are also supported
|
||||
:
|
||||
: note that /inline/ *markup* ignored
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
|
|
1
org/testdata/blocks.pretty_org
vendored
1
org/testdata/blocks.pretty_org
vendored
|
@ -29,6 +29,7 @@ src, example & export blocks treat their content as raw text
|
|||
|
||||
: examples like this
|
||||
: are also supported
|
||||
:
|
||||
: note that /inline/ *markup* ignored
|
||||
|
||||
#+BEGIN_QUOTE
|
||||
|
|
2
org/testdata/headlines.org
vendored
2
org/testdata/headlines.org
vendored
|
@ -1,4 +1,4 @@
|
|||
#+SETUP_FILE: setup_file_org
|
||||
#+SETUPFILE: setup_file_org
|
||||
* Simple Headline [1/2]
|
||||
- [X] checked
|
||||
- [ ] unchecked
|
||||
|
|
2
org/testdata/headlines.pretty_org
vendored
2
org/testdata/headlines.pretty_org
vendored
|
@ -1,4 +1,4 @@
|
|||
#+SETUP_FILE: setup_file_org
|
||||
#+SETUPFILE: setup_file_org
|
||||
* Simple Headline [1/2]
|
||||
- [X] checked
|
||||
- [ ] unchecked
|
||||
|
|
2
org/testdata/lists.pretty_org
vendored
2
org/testdata/lists.pretty_org
vendored
|
@ -26,7 +26,7 @@
|
|||
and text with an empty line in between as well!
|
||||
- unordered list item 4
|
||||
: with an example
|
||||
:
|
||||
:
|
||||
: that spans multiple lines
|
||||
|
||||
|
||||
|
|
2
org/testdata/misc.html
vendored
2
org/testdata/misc.html
vendored
|
@ -43,7 +43,7 @@ src block
|
|||
</p>
|
||||
<div class="highlight">
|
||||
<pre>
|
||||
#+SETUP_FILE: setup_file_org
|
||||
#+SETUPFILE: setup_file_org
|
||||
* Simple Headline [1/2]
|
||||
- [X] checked
|
||||
- [ ] unchecked
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue