Comments (7)
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.
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:
Note that it also uses its own table printer.
from node-html-to-text.
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.
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.
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.
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.
Yeah, can use more specific selectors to format tables differently.
from node-html-to-text.
Related Issues (20)
- Encoding issue HOT 1
- Scraper options selector skip doesnt work HOT 2
- h1 and P are conflicting HOT 2
- how to convert url to markdown ? HOT 5
- tableToString(rows, formatOptions.rowSpacing ?? 0, formatOptions.colSpacing ?? 3), Unexpected token '?' HOT 2
- Is there a way to not parse images? HOT 1
- ul tag without text wrap HOT 2
- I can't use unorderedListItemPrefix for orderedList HOT 2
- Named export 'render' not found HOT 4
- How do you decode & convert in one pass? HOT 3
- TypeError: htmlToText.fromString is not a function HOT 5
- Cannot remove newlines between tags even with options HOT 1
- add typescript and support esm HOT 2
- Issue with selector: "*" HOT 2
- Maximum call stack size exceeded RangeError: Maximum call stack size exceeded HOT 1
- Convert is not a function error HOT 2
- How do i prevent newlines when using whole page as a json object which should singleline HOT 2
- Preview extracted correctly, but actual content is missing HOT 2
- How to use html-to-text using cdn i.e. via <script> HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-html-to-text.