Git Product home page Git Product logo

pandiff's Introduction

PanDiff

Build Status Gitpod ready-to-code

Features

Installation

First install Pandoc and npm, then run:

npm install -g pandiff

Usage

pandiff test/old.md test/new.md
{~~Old~>New~~} Title
====================

{--![image](minus.png)--}

{++![image](plus.png)++}

1.  Lorem ipsum dolor {++sit ++}amet
2.  {++[consectetur adipiscing
elit](https://en.wikipedia.org/wiki/Lorem_ipsum)++}
3.  Lorem{-- ipsum--} dolor sit amet

I really love *italic {~~fonts~>font-styles~~}* {~~here.~>there.~~}

``` diff
 print("Hello")
-print("world.")
+print("world!")
 print("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt")
```

Don’t go around saying {--to people that --}the world owes you a
living. The world owes you nothing. It was here first. {~~One~>Only
one~~} thing is impossible for God: To find{++ any++} sense in any
copyright law on the planet. Truth is stranger than fiction, but it is
because Fiction is obliged to stick to possibilities; Truth isn’t.

Options

pandiff --help
Usage: pandiff [OPTIONS] FILE1 FILE2
      --bibliography=FILE
      --csl=FILE
      --columns=NUMBER
      --extract-media=PATH
  -F, --filter=STRING
  -f, --from=FORMAT
  -h, --help
      --highlight-style=STRING
      --lua-filter=FILE
      --mathjax=BOOL
      --mathml=BOOL
  -o, --output=FILE
      --pdf-engine=STRING
      --reference-dic=FILE
      --reference-links
      --resource-path=PATH
  -s, --standalone
  -t, --to=FORMAT
  -v, --version
      --wrap=STRING

Git integration

Configure git by running the following commands:

git config --global difftool.pandiff.cmd 'pandiff "$LOCAL" "$REMOTE"'
git config --global alias.pandiff 'difftool -t pandiff -y'

Now you can use git pandiff wherever you would usually use git diff.

HTML output

pandiff old.md new.md -s -o diff.html

PDF output

pandiff old.md new.md -o diff.pdf

Word Track Changes

pandiff old.md new.md -o diff.docx
pandiff test/track_changes_move.docx
Here is some text.

{++Here is the text to be moved.++}

Here is some more text.

{--Here is the text to be moved.--}

pandiff's People

Contributors

davidar avatar dependabot[bot] avatar poplarshift avatar ptgolden avatar thepudding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pandiff's Issues

produce diff even if images are missing

When images are missing, pandoc fails with

pandoc: /Sites/Handelshogskolan/Static/Images/apsia.svg: withBinaryFile: does not exist (No such file or directory)

And then pandiff does not output any diff.

It would be great that pandiff gracefully handles missing images.

Thanks for the great tool!

YAML meta data ignored

Thank you for your great package. Unfortunately there seems to be a problem with YAML blocks for meta information. I defined my title there, but it is ignored when creating the diff file (warning pushed and default empty title inserted) . I can't pass additional arguments either. Can this please be fixed? It is very unfavorable, if the title is not considered.

Wrong CriticMarkup output when used to gfm option

Issue happened when try to get diff result in CriticMarkup and pass to: gfm option.

  • Insert output looks fine: {++Hey++}

  • Delete output: {–Hey–} ('–' instead of '--')

  • Substitution output: {\\\\~<sub>protect access,</sub>\\\\>protect,\\\\~\\\\~}

  • It also adds \n characters on the same places in md text despite of wrap: preserver/none or columns options. Seems like it just ignores them while using to: gfm

  • Wrong result with CriticMarkup errors variations also happened when tried to: commonmark, to: markdown.

Could not convert TeX math and Package inputenc Error when converting to PDF

I'm getting the following two errors when running pandiff.

[WARNING] Could not convert TeX math '\textrm{PPV} = \frac{55}{210} = 0.26', rendering as TeX

which may be avoided by adding --mathjax to the command line.

! Package inputenc Error: Unicode char \u8:  not set up for use with LaTeX.
…
Try running pandoc with --pdf-engine=xelatex.

which may be avoided by adding --pdf-engine=xelatex to the command line.

Any suggestions how to fix this?

In the same run, I also get this error:

(node:45417) UnhandledPromiseRejectionWarning: 43
(node:45417) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:45417) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Feature request: Allow - (stdin) as input file name

I have a workflow in which I would like to use,

git show tag:foo.md | pandiff - foo.md

However, this hangs. Instead what I end up doing is,

T=$(mktemp)
git show tag:foo.md > $T
pandiff $T foo.md

So the request is that pandiff allow - as an input file without hanging.

Thanks.

--output breaks --wrap

pandiff old.md new.md --wrap none --output diff.md --> wrap property is ignored and diff is wrapped
pandiff old.md new.md --wrap none > diff.md --> wrap property is used and diff isn't wrapped

How to apply pandoc filter

This is a wonderfull tool!! I am just wondering how one could apply other pandoc filter like cite-proc or eqnos.

Not enough documentation on command usage

As of now this is the only, beside the somewhat vague -h, there is not much doc on commands options and usage.
Could add --help flag on top of commands to make the parameters more clear. Right now is kind of a guessing game.
image

Get table as html in default markdown + CriticMarkup output

Used default pandiff output with atx-headers and wrap: preserve options.

Input:
## Data Protection Principles\n\n* We identify Non-public data and label it as such\n* We put in place reasonable and appropriate safeguards to protect you, corruption, and modification to data\n* We limit PII collection, sharing, disclosure, and use to business need\n* Yes\n\nSystem | Tolerable outage (RTO) | Tolerable data loss (RPO)\n-- | -- | --\nApplication | 24 hours | 24 hours\nNetwork | 24 Hours | 24 hours\n\n

Output:
## Data Protection Principles\\n\\n- We identify Non-public data and label it as such\\n- We put in place reasonable and appropriate safeguards to protect you, corruption, and modification to data\\n- We limit PII collection, sharing, disclosure, and use to business need\\n- Yes\\n\\n<table>\\n<thead>\\n<tr class=\\\"header\\\">\\n<th>\\nSystem\\n</th>\\n<th>\\nTolerable outage (RTO)\\n</th>\\n<th>\\nTolerable data loss (RPO)\\n</th>\\n</tr>\\n</thead>\\n<tbody>\\n<tr class=\\\"odd\\\">\\n<td>\\nApplication\\n</td>\\n<td>\\n24 hours\\n</td>\\n<td>\\n24 hours\\n</td>\\n</tr>\\n<tr class=\\\"even\\\">\\n<td>\\nNetwork\\n</td>\\n<td>\\n24 Hours\\n</td>\\n<td>\\n24 hours\\n</td>\\n</tr>\\n</tbody>\\n</table>\\n

MWE for bibliography

Thanks for this great program! I'm looking to convert changes between two tex files to docx; including in-text references and a bibliography. However, specifying a bibliography has no effect, and adding a csl file results in an error message:

/usr/lib/node_modules/pandiff/node_modules/command-line-args/dist/index.js:1350
        throw err
        ^

UNKNOWN_OPTION: Unknown option: --csl=/path/to/apa.csl
    at commandLineArgs (/usr/lib/node_modules/pandiff/node_modules/command-line-args/dist/index.js:1347:21)
    at Object.<anonymous> (/usr/lib/node_modules/pandiff/cli.js:77:6)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  optionName: '--csl=/path/to/apa.csl'
}

I'm effectively running pandiff --csl=/path/to/apa.csl --bibliography=/path/to/references.bib -o output.doxc old.tex new.tex

Is there something I'm doing wrong? Otherwise it would also be helpful to have a MWE for this kind of case.

more coherent diffs

In the resulting output (screenshot of docx below) the diffs aren't friendly. Notice the sentence "Additionally, the lessons learned from that time are at risk of being forgotten" is fragmented, part of it is buried in deleted text and the rest follows all the deleted text. Is there a diff option that could improve on this?

Screen Shot 2019-10-02 at 4 41 09 PM

Add support fot git vcs

I would be nice to add support for files in git repository:

# diff actual working copy with the last commit in actual branch
pandiff path/to/file.md 

# diff actual working copy with the version in tag/brach/commit
pandiff path/to/file.md <tag/brach/commit>

# diff version of file in tag1/brach1/commit1 with the version in tag2/brach2/commit2
pandiff path/to/file.md <tag1/brach1/commit1> <tag2/brach2/commit2> 

Multiple adjacent inserted paragraphs smooshed together in HTML output

When a diff results in two or more adjacent paragraph insertions, the HTML output returns as if they are one giant paragraph. (I would imagine this applies to two or more adjacent deletions as well).

I've tracked it down to the point in postprocess when pandoc is run on the markdown representation of the diffed output. It seems like pandoc does not count a new paragraph as a paragraph if it's completely wrapped in <ins> or <del> tags. This means that this Markdown:

<ins>Paragraph 1</ins>

<ins>Paragraph 2</ins>

When run through pandoc results in:

<ins>Paragraph 1</ins>
<ins>Paragraph 2</ins>

If, for example, spaces are inserted before the <ins> tags in the above markup, the correct output is produced:

<p><ins>Paragraph 1</ins></p>
<p><ins>Paragraph 2</ins></p>

As a quick workaround, I added this line in postrender before the final pandoc call. It produces the correct output, but I don't know if it's the best solution.

text = text.replace(/\n\n<ins>/g, '\n\n <ins>')

Any thoughts?

(I'm running pandoc 2.2.1.)

only show the changed content?

Hi @davidar

as far as I understand, pandiff shows the full document.

how could one show only the diff, as a typical unified diff, with a bit of context before and after the changes?

thanks!

Feature request: track changes for DOCX, but output to Markdown

I would like a Markdown output file with Pandoc-style track changes markup instead of CriticMarkup. There doesn't appear to be a combination of command line options that gives this result. This is what I end up doing instead,

T=$(mktemp)
pandiff old.md new.md -t docx -o ${T}
pandoc -f docx - markdown+mark --track-changes=all ${T}

The reason is that my workflow does some transformations on the markdown before running it through Pandoc to generate DOCX files:

pandiff old.md new.md -t docx_but_markdown | frob-the-markdown | pandoc -t docx -o output.docx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.