Giter Club home page Giter Club logo

Comments (7)

ElectricCodeGuy avatar ElectricCodeGuy commented on August 17, 2024 1

Thank you, I got it working :) The issue was the HTML i'm trying to parse have a table nested inside another table...
https://www.retsinformation.dk/eli/lta/2024/934#idf61add5b-0d98-4297-8677-1e4565b7e7cb
The table here. So it would just wrap one border around it and extract the html directly. But got it working :)
Love the Package!

from node-html-to-text.

KillyMXI avatar KillyMXI commented on August 17, 2024

I have html-to-markdown converter in the works.
Unfortunately, it's not production-ready yet, and only good on well-formed input.
A lot of unfortunate things aligned, preventing me from investing more time into it currently.
I intend to complete it, but I don't have ETA.
With arbitrary text output we can freehand certain things and avoid some corner cases. Markdown requires more attention.

You can look at my implementation of markdown table formatter there:

function formatDataTable (elem, walk, builder, formatOptions) {

Note that it also uses its own table printer.

from node-html-to-text.

ElectricCodeGuy avatar ElectricCodeGuy commented on August 17, 2024

Thanks for quick response! I have been using this and it seems to output the table structured as a table if i check the output. But if i apply a markdown renderer like React Markdown it does not render it as a table. It just render it like normal lines with a \n at the end of each row in the table

from node-html-to-text.

KillyMXI avatar KillyMXI commented on August 17, 2024

I don't understand what you mean.

html-to-text has its own dataTable formatter that is not compatible with markdown.

html-to-markdown will be a separate package with its own set of formatters.
They may have similar names, so pay attention which package they are in.

Formatters API is the same, but I don't ship markdown formatters in any published package yet.
The code in the repository is work in progress.

You can bring any existing formatter as a custom formatter by copying the code, but data tables have most complex formatters and require more effort and understanding to do so.
(And pay closer attention to the license as well, when copying code instead of importing. MIT still requires attribution.)


In case you're actually using html-to-md from the repository and having issues with produced markdown - that's a separate story. I've no idea what markdown flavor React Markdown supports, whether I already support it through configuration, or whether there are other issues.
That's why I'm not publishing it in current state - I don't want to deal with a lot of problems that people will report before I implement a solid solution for them.

from node-html-to-text.

ElectricCodeGuy avatar ElectricCodeGuy commented on August 17, 2024

Hey sorry for bad response before. It does make it into a table that is nice, but is it possible to also make it do all the | -- | signs so a table will render using a markdown rendered like reactmarkdown ? :)

from node-html-to-text.

KillyMXI avatar KillyMXI commented on August 17, 2024

Yes.
But that requires some understanding.
I have the code you might be able to use for rendering markdown tables - I linked it before.
But you have to understand what parts you need to copy into your code and wire in the options.

I don't want to spoonfeed because this is rather advanced use and will be obsolete in the future.

I simply can't focus on the project currently, to complete it in the intended form to have a simpler solution for you.

from node-html-to-text.

KillyMXI avatar KillyMXI commented on August 17, 2024

Yeah, can use more specific selectors to format tables differently.

from node-html-to-text.

Related Issues (20)

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.