Commit graph

13149 commits

Author SHA1 Message Date
Albert Krewinkel
6cd77d4c63
Resolve HLint warnings
All warnings are either fixed or, if more appropriate, HLint is
configured to ignore them. HLint suggestions remain.

  * Ignore "Use camelCase" warnings in Lua and legacy code
  * Fix or ignore remaining HLint warnings
  * Remove redundant brackets
  * Remove redundant `return`s
  * Remove redundant as-pattern
  * Fuse mapM_/map
  * Use `.` to shorten code
  * Remove redundant `fmap`
  * Remove unused LANGUAGE pragmas
  * Hoist `not` in Text.Pandoc.App
  * Use fewer imports for `Text.DocTemplates`
  * Remove redundant `do`s
  * Remove redundant `$`s
  * Jira reader: remove unnecessary parentheses
2020-02-07 10:17:24 +01:00
Joseph C. Sible
60a3158bf9
More in-depth refactoring and cleanup (#6123)
* Avoid duplicating the dash case

* Pull common functions out of case branches

* Make sure list lengths are only calculated once

* Use unless

* Simplify parseURIReference' and avoid an unnecessary call to length

* Use <$> instead of reimplementing it

* Use swap instead of reimplementing it

* Remove eta-expansion that's been unnecessary since 90f5dd8

* Use tailDef instead of reimplementing it

* Use second instead of fmap, per @tarleb
2020-02-07 08:42:46 +01:00
Joseph C. Sible
a5a3ac9946
Various minor cleanups and refactoring (#6117)
* Use concatMap instead of reimplementing it

* Replace an unnecessary multi-way if with a regular if

* Use sortOn instead of sortBy and comparing

* Use guards instead of lots of indents for if and else

* Remove redundant do blocks

* Extract common functions from both branches of maybe

Whenever both the Nothing and the Just branch of maybe do the same
function, do that function on the result of maybe instead.

* Use fmap instead of reimplementing it from maybe

* Use negative forms instead of negating the positive forms

* Use mapMaybe instead of mapping and then using catMaybes

* Use zipWith instead of mapping over the result of zip

* Use unwords instead of reimplementing it

* Use <$ instead of <$> and const

* Replace case of Bool with if and else

* Use find instead of listToMaybe and filter

* Use zipWithM instead of mapM and zip

* Inline lambda wrappers into the real functions

* We get zipWithM from Text.Pandoc.Writers.Shared

* Use maybe instead of fromMaybe and fmap

I'm not sure how this one slipped past me.

* Increase a bit of indentation
2020-02-07 08:38:24 +01:00
Joseph C. Sible
013a1647a7
Use traverse instead of reimplementing it (#6124) 2020-02-06 23:10:09 -08:00
Joseph C. Sible
30c8980883
Simplify an overcomplicated filtering function (#6115)
There's no need to use `catMaybes`, `uncurry`, `bool`, etc., just
to get elements where the second element of a tuple is True.
2020-02-05 17:22:53 -08:00
John MacFarlane
9c12024e07 Fix --number-offset with HTML TOC.
Eventually it would be worth adding a parameter to
makeSections so this could be done at that level;
then it would also affect other writers that construct
TOC manually.
2020-02-05 17:20:52 -08:00
John MacFarlane
0a4f49d370 MediaWiki writer: prevent triple [[[.
This confuses mediawiki's parser.  So we insert a `<nowiki/>`
no-op between a literal `[` and a link.  Closes #6119.
2020-02-05 10:08:18 -08:00
John MacFarlane
9c4dc8b49b LaTeX reader: skip comments in more places where this is needed.
Closes #6114.
2020-02-05 09:48:42 -08:00
Joseph C. Sible
b018028ee9
Remove our bool function (#6116)
Data.Bool already provides a bool function identical to this one.
2020-02-04 22:38:49 -08:00
John MacFarlane
fd9c03febe Add timing info for filters in --verbose mode.
+ Add RunningFilter, FilterCompleted constructors to LogMessage
+ When verbose mode is specified (verbosity == INFO), print a
  notice when running a filter and when a filter completes (including
  timing).

Closes #6112.
2020-02-04 09:38:53 -08:00
John MacFarlane
30962e2e9d Allow & in LaTeX citation keys.
Closes #6110.
2020-02-03 20:38:49 -08:00
Joseph C. Sible
1ea5b18020
Swap suboptimal uses of maybe and fromMaybe (#6111)
Anywhere "maybe" is used with "id" as its second argument, using
"fromMaybe" instead will simplify the code. Conversely, anywhere
"fromMaybe" is used with the result of "fmap" or "<$>" as its second
argument, using "maybe" instead will simplify the code.
2020-02-03 20:31:05 -08:00
John MacFarlane
d9b1776336 Fix duplicate frame classes in LaTeX/Beamer output.
Close #6107.
2020-02-03 08:52:07 -08:00
Joseph C. Sible
6371ec241d
Clean up overcomplicated maybe logic (#6105)
We're using maybe in redundant ways. Remove it altogether in one case and
simplify it to fromMaybe in another.
2020-02-03 08:26:00 -08:00
Joseph C. Sible
8d6fac1253
Clean up a confusing triple negative (#6102)
There's currently `unless`, `not`, and `notParaOrPlain` in the same
expression, which is a rather confusing triple negative. Replace
`notParaOrPlain` with `paraOrPlain` and switch to `all` from `any`
to clean this up.
2020-02-03 08:14:22 -08:00
John MacFarlane
b47a3cdcb6 Text.Pandoc.Readers.CSV - reuse CSV parser from Text.Pandoc.CSV. 2020-02-01 07:34:15 -08:00
John MacFarlane
4b1f8584a5 Fix bug in Text.Pandoc.CSV.
Previously an extra blank record would sometimes be inserted at the
end.
2020-02-01 07:33:55 -08:00
John MacFarlane
22f484e9a9 Support 'bibliography' and 'csl' fields in defaults file.
Move addMeta from T.P.App.CommandLineOptions to T.P.App.Opt.
(not an api change because modules not exported)
2020-01-31 21:56:28 -08:00
John MacFarlane
fb3df6cf19 csv reader: allow empty cells. 2020-01-31 21:43:19 -08:00
John MacFarlane
f9514ccb9e Add Text.Pandoc.Readers.CSV (readCSV).
This adds csv as an input format.
The CSV table is converted into a pandoc simple table.

Closes #6100.
2020-01-31 21:14:21 -08:00
John MacFarlane
cef30e7384 LaTeX template: add space option to xeCJK with PassOptionsToPackage.
Otherwise we can get a clash with documentclasses that
already load the package.  Closes #6002.
2020-01-29 21:47:24 -08:00
John MacFarlane
e6399d162a Added a try that was needed for the commit fc78be1.
The intent of that commit was to parse unknown LaTeX
enivronments as verbatim if they can't be parsed normally,
avoiding crashes on environments that allow unescaped
underscores and the like.  But the fix didn't completely
work: it worked for raw TeX in markdown but not when
reading LaTeX. This change fixes that.

See #6034. Closes #6093.
2020-01-28 21:32:30 -08:00
Salim B
34eba446a0 Update URLs and use HTTP**S** wherever possible (#6090)
I've changed _all_ `http:` URLs in the file to their `https` equivalents if the respective sites have properly configured HTTPS.
2020-01-27 15:46:33 -08:00
John MacFarlane
05a217091f Fix test suite for new skylighting.
Closes #6086.
2020-01-27 08:25:25 -08:00
John MacFarlane
3b4dc3a2b0 Use skylighting 0.8.3.2. 2020-01-21 17:57:23 -08:00
John MacFarlane
761ece90c9 Windows rc: Create the release dir. 2020-01-21 17:56:31 -08:00
John MacFarlane
ff4dd2b1dd
Docx writer: fix regression with Compact style on tight lists. (#6073)
Starting in 2.8, the docx writer no longer distinguishes
between tight and loose lists, since the Compact style is
omitted.

This is a side-effect of the fix to #5670, as explained
in the changelog:

    + Preserve built-in styles in DOCX with custom style (Ben Steinberg,
      #5670).  This change prevents custom styles on divs and spans
      from overriding styles on certain elements inside them, like
      headings, blockquotes, and links. On those elements, the
      "native" style is required for the element to display correctly.
      This change also allows nesting of custom styles; in order to do so,
      it removes the default "Compact" style applied to Plain blocks,
      except when inside a table.

This patch fixes the problem by extending the exception currently
offered to Plain blocks inside tables to Plain blocks inside list
items.

Closes #6072.
2020-01-19 18:24:32 -08:00
John MacFarlane
5028278569 windows release candidate build: More fixes to get 'light' to work. 2020-01-18 16:02:28 -08:00
Albert Krewinkel
6c8ed00e7b
doc/lua-filters.md: fix copy-paste mistake
Closes: #6040
2020-01-18 22:02:52 +01:00
John MacFarlane
2895fdccfb Windows ci: Add binpath when doing 'light'. 2020-01-18 12:15:56 -08:00
John MacFarlane
adc14ff245 Windows ci - fix path to COPYING.rtf in dialog. 2020-01-18 09:33:05 -08:00
John MacFarlane
9570576fa9 Fix typo in windows ci build. 2020-01-18 09:30:17 -08:00
John MacFarlane
c78af6f3a6 Use versioned directory for windows release zipfile.
Also remove old make-windows-installer.bat, superseded
by GitHub actions workflow, and modify pandoc.wxs for
new paths.
2020-01-17 15:37:49 -08:00
John MacFarlane
aa5903705a Add --rm to docker command in INSTALL.md. 2020-01-17 08:56:36 -08:00
Albert Krewinkel
672a4bdd1d Lua filters: allow filtering of element lists (#6040)
Lists of Inline and Block elements can now be filtered via `Inlines` and
`Blocks` functions, respectively. This is helpful if a filter conversion
depends on the order of elements rather than a single element.

For example, the following filter can be used to remove all spaces
before a citation:

    function isSpaceBeforeCite (spc, cite)
      return spc and spc.t == 'Space'
       and cite and cite.t == 'Cite'
    end

    function Inlines (inlines)
      for i = #inlines-1,1,-1 do
        if isSpaceBeforeCite(inlines[i], inlines[i+1]) then
          inlines:remove(i)
        end
      end
      return inlines
    end

Closes: #6038
2020-01-15 14:26:00 -08:00
John MacFarlane
400b29d10e INSTALL: remove bullets 2020-01-15 09:16:07 -08:00
John MacFarlane
7b339d02a0 Add Docker and GH Actions instructions/links to INSTALL.md. 2020-01-15 09:09:34 -08:00
John MacFarlane
ebf413cdec Update filters doc with better cabal v2 instructions. 2020-01-14 16:31:09 -08:00
John MacFarlane
dfac1239d9 Update filter documentation.
Remove example using pandoc API directly (we have other
docs for that and it was outdated).

Closes #6065.
2020-01-14 11:18:24 -08:00
John MacFarlane
9009bda179 Update versions for doclayout, doctemplates.
Closes #6031.  The new version of doclayout fixes a
memory leak that affected `--include-in-header` with
large files (and possibly other cases involving extremely
long lines).
2020-01-13 08:39:25 -08:00
John MacFarlane
157936c927 HTML writer: fix duplicate attributes on headings.
Another regression from 2.7.x. Closes #6062.
2020-01-12 15:18:37 -08:00
Albert Krewinkel
11e99409ce
docs: capitalize Lua where it refers to the programming language name
This follows the advise on the Lua
website (https://www.lua.org/about.html#name):

> […] "Lua" is a name, the name of the Earth's moon and the name of the
> language. Like most names, it should be written in lower case with an
> initial capital, that is, "Lua".
2020-01-12 11:29:05 +01:00
Albert Krewinkel
6fd3d546a2
Lua filter docs: cross-link constructors and types
Thanks to @bpj for the idea.
2020-01-11 23:51:07 +01:00
Albert Krewinkel
4ede11a75f
Lua: add methods insert, remove, and sort to pandoc.List
The functions `table.insert`, `table.remove`, and `table.sort` are added
to pandoc.List elements.  They can be used as methods, e.g.

    local numbers = pandoc.List {2, 3, 1}
    numbers:sort()     -- numbers is now {1, 2, 3}
2020-01-11 21:31:20 +01:00
Albert Krewinkel
23d81081d0
doc/lua-filters.md: sort pandoc.List methods alphabetically 2020-01-11 21:29:47 +01:00
Albert Krewinkel
802a566f93
data/pandoc.List.lua: improve internal documentation 2020-01-11 21:25:53 +01:00
Albert Krewinkel
d09bcc7f16 doc/lua-filters.md: unify, fix anchors and internal links (#6061)
Links and anchors now follow consistent conventions, like lowercase-only
anchor names.

This breaks some links to specific sections in the document, but will
make it much easier to link documentation in the future.
2020-01-11 11:55:02 -08:00
Albert Krewinkel
e98921ae57
pandoc.List.lua: make pandoc.List a callable constructor
It is now possible to construct a new List via `pandoc.List()` instead of
`pandoc.List:new()`.
2020-01-11 19:38:27 +01:00
Albert Krewinkel
57637f8aae
Add tests for pandoc.List module 2020-01-11 17:42:32 +01:00
Albert Krewinkel
467ea4e02c docs/lua-filters.md: clarify filter function execution order (#6059) 2020-01-10 15:19:26 -08:00