diff --git a/org/keyword.go b/org/keyword.go index d4bd233..c166b95 100644 --- a/org/keyword.go +++ b/org/keyword.go @@ -35,7 +35,7 @@ type Include struct { } 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 attributeRegexp = regexp.MustCompile(`(?:^|\s+)(:[-\w]+)\s+(.*)$`) diff --git a/org/org_writer.go b/org/org_writer.go index 4b4d2a4..c502c76 100644 --- a/org/org_writer.go +++ b/org/org_writer.go @@ -207,7 +207,7 @@ func (w *OrgWriter) WriteNodeWithName(n NodeWithName) { } 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...) } diff --git a/org/testdata/keywords.html b/org/testdata/keywords.html index 7e39d4b..06c3e27 100644 --- a/org/testdata/keywords.html +++ b/org/testdata/keywords.html @@ -25,3 +25,4 @@ named block +
#not a comment because there's no space after the hashtag
diff --git a/org/testdata/keywords.org b/org/testdata/keywords.org index 440949d..dc59ed1 100644 --- a/org/testdata/keywords.org +++ b/org/testdata/keywords.org @@ -20,3 +20,6 @@ named paragraph #+begin_src named block #+end_src + +# comments must have whitespace after the hashtag +#not a comment because there's no space after the hashtag diff --git a/org/testdata/keywords.pretty_org b/org/testdata/keywords.pretty_org index 7b0bf23..2e309eb 100644 --- a/org/testdata/keywords.pretty_org +++ b/org/testdata/keywords.pretty_org @@ -20,3 +20,6 @@ named paragraph #+BEGIN_SRC named block #+END_SRC + +# comments must have whitespace after the hashtag +#not a comment because there's no space after the hashtag