News for hackers. Stuff that matters.
Re:pandoc -f html -t markdown https://www.fsf.org by dredmorbius on Thursday June 22, 2023 @09:31AM (#36431886)
Pandoc is one of my favourite tools of the past decade.

Most often I'm using it to create HTML or PDF output from Markdown source, though it can also be used to bootstrap LaTeX documents.

Looking over the conversion formats, I'm noticing that pandoc accepts JSON as either a source or output format.

Given some recent web-scraping projects I've been engaged with, this ... looks interesting, particularly married to my other favourite new tool, jq, for parsing and manipulating JSON output....

Hrm...

Re:pandoc -f html -t markdown https://www.fsf.org by rurban on Thursday June 22, 2023 @09:26AM (#36431828)
uh. Not really good markdown

    ::: {#fsf-links-outer}
    ::: {#fsf-links .yui-g .visualNoPrint .noMobile}
    <div>

    ::: yui3-g-r
    ::: {.yui3-u-1-2 .yui3-g-r .first}
    ::: {#sitemap-1 .yui3-u-1-2 .first}
There are much better HTML to MD Converters
Re:pandoc -f html -t markdown https://www.fsf.org by fiddlosopher on Thursday June 22, 2023 @06:55PM (#36440335)
If you don't want pandoc's fenced divs, just choose a markdown dialect that doesn't support them: e.g.,

    pandoc -f html -t gfm https://www.fsf.org
Or, to get rid of the divs and spans altogether, disable raw HTML as well:

    pandoc -f html -t gfm-raw_html https://www.fsf.org
Re:pandoc -f html -t markdown https://www.fsf.org by rurban on Friday June 23, 2023 @08:45AM (#36446077)
those have even raw div's then.

    ...
    </div>
    <div id="sitemap-2" class="yui3-u-1-2 first">
    ...
Re:pandoc -f html -t markdown https://www.fsf.org by fiddlosopher on Friday June 23, 2023 @04:44PM (#36451962)
As I explained, if you don't want raw HTML, use the second form:

  pandoc -f html -t gfm-raw_html https://www.fsf.org | grep div
gives no output. (If you get different results, it is possible that you are using an earlier pandoc version and something changed in this regard.)
Re:pandoc -f html -t markdown https://www.fsf.org by surprisetalk on Thursday June 22, 2023 @09:05AM (#36431538)
The markdown seems a bit messy, so I tend to prefer the plaintext output:

  pandoc -f html -t plain https://www.fsf.org
I don't have an application yet, but it's nifty :)
Re:pandoc -f html -t markdown https://www.fsf.org by dredmorbius on Thursday June 22, 2023 @09:33AM (#36431922)
It's an interesting commentary that often the most straightforward way to convert from HTML to another format ... is to dump it straight to ASCII and add in the tagging manually.

I've done this for even very long documents (book length). Given the choice of manually proofing or manually editing, the latter generally seems preferable. Either way I've got to Read The Whole Damned Thing.