-
-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extraction: improve spacing in item, cell and code blocks #772
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #772 +/- ##
==========================================
+ Coverage 99.27% 99.29% +0.01%
==========================================
Files 21 21
Lines 3601 3663 +62
==========================================
+ Hits 3575 3637 +62
Misses 26 26 ☔ View full report in Codecov by Sentry. |
Hi @unsleepy22, a few comments on the PR:
Last, if you have several PRs in store about unrelated parts of the code it would be best to send them all at once, I don't plan to maintain the software on a day-to-day basis, we could both save time by grouping requests. |
Sorry for late response as I have been on vacation for a few days. Yes, this fixes Preserve horizontal space in code blocks #553. The Another change I'd like to make but needs discussion is adding another option like |
|
It's ok with me to make Currently if |
OK then, you can change the code of Concerning |
Hi @unsleepy22, are you available to make the final changes to the PR? |
Sorry it's been quite a while, got a bit busy on work stuff (and a long Chinese Spring Festival vacation). I think it'll take a few more days to fix the changes. |
That's fine, 蛇年祝福 ! |
Also I forced a space after highlighted text for better compatibility with various markdown editors as some md editor will fail to render for text like BTW, #776 looks more elegant in handling code blocks, if it also fixes #553 , I think my PR would be a duplicate fix? I'm OK to merge #776 and simplify my PR. @adbar what do you think? |
OK then, I will merge #776 and then you can simplify this PR. I don't really like the idea of adding a space but if it's a common way to write markdown then why not. |
@unsleepy22 Everything looks good but can you please remove the additional spacing? Or do you have a format specification for this? I checked Markdown and Commonmark, the current syntax in master is correct. |
2777f85
to
c1b8a9f
Compare
OK all fixed, would you take a look again? |
trafilatura/core.py
Outdated
@@ -487,7 +488,7 @@ def extract_with_metadata( | |||
include_images: Take images into account (experimental). | |||
include_formatting: Keep structural elements related to formatting | |||
(only valuable if output_format is set to XML). | |||
include_links: Keep links along with their targets (experimental). | |||
= include_links: Keep links along with their targets (experimental). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@unsleepy22 Could you please remove it if necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, maybe mis-typed this.
@unsleepy22 The PR looks good. however I just ran tests on the benchmark and the extraction is really slow after your PRs, it gets even slower after this one. I think we need to fix this. |
OK I'll see to it. |
Thanks, this is much better but the fast mode (without extraction fallbacks) is still slower than the full mode. Could you do something about that? Edit: The fast mode is not only slower, now the results are the same as in full mode, so I believe extraction steps happen which shouldn't be there. |
Do you mean fast mode in master branch is faster than fast mode in my PR? I checked both on my M4 max and MBP 2019, both show no significant performance gap (average on 30 runs, less than 30ms performance gap on MBP out of avg 1800ms/call and less than 5ms gap on M4 max out of avg 300ms/call). I ran another test which shows that fast mode produces different result with full mode(also checked that
|
@unsleepy22 Yes, the problem is now that the "fast" mode isn't faster than the other anymore (somewhere after your first PRs). Not a huge deal but something we could address in another PR. |
I run comparison_small.py locally, looks it always costs 20+ secs in whichever branch (v1.2.2, v2.0.0, current master, my PR). |
@unsleepy22 Yes, it has been like this since one of your recent PRs, I'm not sure which, we would have to test. Please get rid of the superfluous lines so that I can merge this PR, you can solve the fast/full issue in another PR if you find a way. |
I'd really like to see this feature present, please merge :) |
Currently preserve_space is forced False in sanitize method when converting xml to text, while for code blocks esp. python code we wish to preserve spaces to keep the original format since space matters in python.