markdown_convert 1.2.45__tar.gz → 1.2.46__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown_convert
3
- Version: 1.2.45
3
+ Version: 1.2.46
4
4
  Summary: Convert Markdown files to PDF from your command line.
5
5
  Project-URL: homepage, https://github.com/Julynx/markdown_convert
6
6
  Author-email: Julio Cabria <juliocabria@tutanota.com>
@@ -34,23 +34,27 @@ def create_html_document(html_content, css_content, csp):
34
34
 
35
35
  def create_sections(html_string):
36
36
  """
37
- Wraps each h2 and its following content in a <section> tag.
38
- Avoids wrapping h2 tags that are inside <code> blocks.
37
+ Wraps each h2 or h3 and its following content in a <section> tag.
38
+ The section ends when the next h2 or h3 is encountered, or the parent ends.
39
39
 
40
40
  Args:
41
41
  html_string (str): The input HTML string.
42
42
  Returns:
43
- str: The modified HTML string with h2 sections wrapped.
43
+ str: The modified HTML string with sections wrapped.
44
44
  """
45
45
  soup = BeautifulSoup(html_string, "html.parser")
46
46
 
47
- for second_level_header in soup.find_all("h2"):
47
+ # Change 1: Search for both h2 and h3 tags
48
+ for header in soup.find_all(["h2", "h3"]):
49
+ # Create the new section
48
50
  new_section = soup.new_tag("section")
49
- second_level_header.insert_before(new_section)
51
+ header.insert_before(new_section)
50
52
 
51
- current = second_level_header
53
+ current = header
54
+
55
+ # Change 2: Update loop to stop if it hits an h2 OR h3 (that isn't the current one)
52
56
  while current is not None and (
53
- current == second_level_header or current.name != "h2"
57
+ current == header or current.name not in ["h2", "h3"]
54
58
  ):
55
59
  next_sibling = current.next_sibling
56
60
  new_section.append(current)
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "markdown_convert"
7
- version = "1.2.45"
7
+ version = "1.2.46"
8
8
  description = "Convert Markdown files to PDF from your command line."
9
9
  authors = [
10
10
  { name = "Julio Cabria", email = "juliocabria@tutanota.com" },