Fix comments: comments must start with #\s not just #

This commit is contained in:
Niklas Fasching 2020-07-28 19:28:30 +02:00
parent 16ccafe8a3
commit c025db7bdd
5 changed files with 9 additions and 2 deletions

View file

@ -35,7 +35,7 @@ type Include struct {
} }
var keywordRegexp = regexp.MustCompile(`^(\s*)#\+([^:]+):(\s+(.*)|$)`) var keywordRegexp = regexp.MustCompile(`^(\s*)#\+([^:]+):(\s+(.*)|$)`)
var commentRegexp = regexp.MustCompile(`^(\s*)#(.*)`) var commentRegexp = regexp.MustCompile(`^(\s*)#\s(.*)`)
var includeFileRegexp = regexp.MustCompile(`(?i)^"([^"]+)" (src|example|export) (\w+)$`) var includeFileRegexp = regexp.MustCompile(`(?i)^"([^"]+)" (src|example|export) (\w+)$`)
var attributeRegexp = regexp.MustCompile(`(?:^|\s+)(:[-\w]+)\s+(.*)$`) var attributeRegexp = regexp.MustCompile(`(?:^|\s+)(:[-\w]+)\s+(.*)$`)

View file

@ -207,7 +207,7 @@ func (w *OrgWriter) WriteNodeWithName(n NodeWithName) {
} }
func (w *OrgWriter) WriteComment(c Comment) { func (w *OrgWriter) WriteComment(c Comment) {
w.WriteString(w.indent + "#" + c.Content + "\n") w.WriteString(w.indent + "# " + c.Content + "\n")
} }
func (w *OrgWriter) WriteList(l List) { WriteNodes(w, l.Items...) } func (w *OrgWriter) WriteList(l List) { WriteNodes(w, l.Items...) }

View file

@ -25,3 +25,4 @@ named block
</pre> </pre>
</div> </div>
</div> </div>
<p>#not a comment because there&#39;s no space after the hashtag</p>

View file

@ -20,3 +20,6 @@ named paragraph
#+begin_src #+begin_src
named block named block
#+end_src #+end_src
# comments must have whitespace after the hashtag
#not a comment because there's no space after the hashtag

View file

@ -20,3 +20,6 @@ named paragraph
#+BEGIN_SRC #+BEGIN_SRC
named block named block
#+END_SRC #+END_SRC
# comments must have whitespace after the hashtag
#not a comment because there's no space after the hashtag