-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change treatment of number-lines
directives.
#5207
Conversation
c36dd4e
to
df873ce
Compare
Hmm, I'm not sure why the CI can't load my file. I'm following the example of |
You probably need to add it expliclitly to extra-source-files in pandoc.cabal. |
df873ce
to
954434a
Compare
src/Text/Pandoc/Readers/RST.hs
Outdated
@@ -505,7 +505,11 @@ includeDirective top fields body = do | |||
let numberLines = lookup "number-lines" fields | |||
let classes = trimr lang : ["numberLines" | isJust numberLines] ++ | |||
maybe [] words (lookup "class" fields) | |||
let kvs = maybe [] (\n -> [("startFrom", trimr n)]) numberLines | |||
let kvs = maybe [] (\n -> let tn = trimr n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
null tn
would be better than tn == ""
. But as a matter of style, I think this is cleaner:
case trimr n of
[] -> []
xs -> [("startFrom", xs)]
Indeed, you could use a list comprehension:
let kvs = [("startFrom", xs) | x <- maybeToList (trimr <$> tn)]
but this probably isn't as clear to the reader.
src/Text/Pandoc/Readers/RST.hs
Outdated
Nothing -> [] | ||
Just n -> [("startFrom",trim n)] | ||
Just n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar remarks to the above.
Directives of this type without numeric inputs should not have a `startFrom` attribute; with a blank value, the writers can produce extra whitespace.
954434a
to
ff3822c
Compare
Done. I also tried to dedupe the code a bit. |
Looks good, thanks! |
Directives of this type without numeric inputs should not have a
startFrom
attribute; with a blank value, the writers can produceextra whitespace.
Also, the stuff around line 1000 is modified because previously, it failed to catch newlines.
Closes #5182.