@@ -72,6 +72,13 @@ def _transform_columns(self) -> None:
7272 Right content
7373 :::
7474
75+ Or with percentage width:
76+ :::columns[60]
77+ Left content (60% width)
78+ |||
79+ Right content (40% width)
80+ :::
81+
7582 Into special markers that the frontend will process:
7683 <!-- COLUMN:LEFT:START -->
7784 Left content (markdown)
@@ -80,6 +87,14 @@ def _transform_columns(self) -> None:
8087 Right content (markdown)
8188 <!-- COLUMN:RIGHT:END -->
8289
90+ Or with width:
91+ <!-- COLUMN:LEFT:START:60 -->
92+ Left content (markdown)
93+ <!-- COLUMN:LEFT:END -->
94+ <!-- COLUMN:RIGHT:START -->
95+ Right content (markdown)
96+ <!-- COLUMN:RIGHT:END -->
97+
8398 The frontend (slides.js) will find these markers and render the markdown
8499 in each column, allowing mermaid diagrams and other features to work.
85100
@@ -99,11 +114,13 @@ def save_code_block(match):
99114 code_block_pattern , save_code_block , self .content , flags = re .DOTALL
100115 )
101116
102- # Pattern to match column blocks (more forgiving with whitespace)
103- column_pattern = r":::columns\s*\n(.*?)\s*\n:::"
117+ # Pattern to match column blocks with optional width percentage
118+ # Matches: :::columns or :::columns[60]
119+ column_pattern = r":::columns(?:\[(\d+)\])?\s*\n(.*?)\s*\n:::"
104120
105121 def replace_columns (match ):
106- content = match .group (1 )
122+ width_percent = match .group (1 ) # Can be None if no width specified
123+ content = match .group (2 )
107124 # Split on ||| separator (more forgiving with whitespace)
108125 parts = re .split (r"\s*\|\|\|\s*" , content , maxsplit = 1 )
109126
@@ -112,9 +129,15 @@ def replace_columns(match):
112129 right_content = parts [1 ].strip ()
113130
114131 # Create marker structure that preserves markdown
132+ # Include width in left column marker if specified
133+ if width_percent :
134+ left_start_marker = f"<!-- COLUMN:LEFT:START:{ width_percent } -->"
135+ else :
136+ left_start_marker = "<!-- COLUMN:LEFT:START -->"
137+
115138 # The frontend will process these markers after marked.js runs
116139 return (
117- "<!-- COLUMN:LEFT:START --> \n "
140+ f" { left_start_marker } \n "
118141 f"{ left_content } \n "
119142 "<!-- COLUMN:LEFT:END -->\n "
120143 "<!-- COLUMN:RIGHT:START -->\n "
0 commit comments