Title
Here is a code sample:
import trafilatura\ntrafilatura.extract("")
Sometimes code is wrapped using pre
and code
:
import trafilatura\ntrafilatura.extract("")
Less often code is wrapped using just pre
:
\n trafilatura.extract("")
diff --git a/tests/unit_tests.py b/tests/unit_tests.py index cfe94583..4ee0be2b 100644 --- a/tests/unit_tests.py +++ b/tests/unit_tests.py @@ -354,15 +354,16 @@ def test_formatting(): Here is a code sample: `import trafilatura`""" - my_document = html.fromstring('
Here is a code sample:
import trafilatura\ntrafilatura.extract("")
Sometimes code is wrapped using pre
and code
:
import trafilatura\ntrafilatura.extract("")
Less often code is wrapped using just pre
:
\n trafilatura.extract("")
Here is a code sample:
import something
something.run("somewhere")
Sometimes code is wrapped using pre
and code
:
import trafilatura\ntrafilatura.extract("")
Less often code is wrapped using just pre
:
\n trafilatura.extract("")
+ # Convert
to \n within code blocks
+ for lb in element.xpath(".//lb"):
+ elem_text = f"{elem_text}\n{lb.tail}"
+ lb.getparent().remove(lb)
elem_text = f"```\n{elem_text}\n```\n"
else:
elem_text = f"`{elem_text}`"