Release v1.9.2: Full-width background for code blocks

Fixed code block and ASCII art background to extend full paragraph width:

🔧 Background Fix:
- Moved shading (w:shd) from run level (<w:rPr>) to paragraph level (<w:pPr>)
- Background now extends full width like in the preview
- Applied to both createCodeBlockXml() and createAsciiArtXml() functions

📝 Technical Changes:
- src/wordTemplateExporter.js: Paragraph-level shading for full-width backgrounds
- Added w:ind with left="284" right="284" for consistent margins
- Removed redundant w:shd from run properties

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-12 09:10:18 +05:30
co-authored by Claude
parent cb98549db8
commit d8e0748037
5 changed files with 15 additions and 12 deletions
+2 -1
View File
@@ -20,7 +20,8 @@
"Read(//c/Program Files/MiKTeX/miktex/bin/x64/**)", "Read(//c/Program Files/MiKTeX/miktex/bin/x64/**)",
"Bash(findstr:*)", "Bash(findstr:*)",
"Bash(cmd /c \"dir /b H:\\Coding\\pan-converter\\dist\\*.exe H:\\Coding\\pan-converter\\dist\\*.zip 2>nul | findstr 1.9.1\")", "Bash(cmd /c \"dir /b H:\\Coding\\pan-converter\\dist\\*.exe H:\\Coding\\pan-converter\\dist\\*.zip 2>nul | findstr 1.9.1\")",
"Bash(cmd /c \"dir H:\\Coding\\pan-converter\\dist\\*1.9.1*\")" "Bash(cmd /c \"dir H:\\Coding\\pan-converter\\dist\\*1.9.1*\")",
"Bash(gh release create v1.9.1 --title \"v1.9.1: ASCII Art & Code Block Preservation\" --notes \"$(cat <<''EOF''\n# Release v1.9.1: ASCII Art & Code Block Preservation\n\n## 🎯 Overview\nThis release fixes the export of ASCII art, charts, tables, and flowcharts to match the preview exactly. Code blocks now export with perfect monospace formatting, preserving all line breaks, spacing, and box-drawing characters.\n\n## 🎨 What''s Fixed\n\n### ASCII Art & Code Block Preservation\n- **Code blocks now export exactly as shown in preview**\n- Each line rendered separately to preserve exact spacing and alignment\n- Monospace font (Consolas) used consistently across all export formats\n- Box-drawing characters, arrows, and flowcharts render correctly\n- No more text wrapping or broken formatting in exports\n\n### Export Format Improvements\n\n#### DOCX (Enhanced) - Word Template Exporter\n- Each code line rendered as separate paragraph with exact spacing\n- Added `<w:keepLines/>` and `<w:wordWrap w:val=\"0\"/>` XML properties\n- Light gray background (#F5F5F5) for visual distinction\n- Perfect alignment preserved for ASCII art and flowcharts\n\n#### PDF Export (All Methods)\n- Added `-V monofont=\"Consolas\"` for proper code block rendering\n- Added `--highlight-style=tango` for syntax highlighting\n- Works with XeLaTeX, PDFLaTeX, and LuaLaTeX engines\n\n#### HTML & Electron PDF Fallback\n- Enhanced CSS: `white-space: pre`, `word-wrap: normal`\n- Print media queries preserve code block formatting\n- `overflow: visible` prevents content truncation\n\n### Improved ASCII Art Detection\n- Extended Unicode box-drawing character support\n- Added rounded corners: ╭╮╯╰\n- Added heavy box characters: ┃━┏┓┗┛┣┫┳┻╋\n- Added more arrow types: ↔↕⇒⇐⇓⇑\n- Additional ASCII patterns detected\n\n## 📦 Available Downloads\n\nChoose the package that suits your needs:\n\n1. **PanConverter-Setup-1.9.1.exe** (Recommended)\n - Full installer with uninstaller\n - File associations and Start Menu shortcuts\n - ~104 MB\n\n2. **PanConverter-1.9.1-x64.exe**\n - Portable executable, no installation required\n - Run directly from any folder\n - ~104 MB\n\n3. **PanConverter-1.9.1-x64.zip**\n - ZIP archive with unpacked application\n - For manual extraction and deployment\n - ~145 MB (uncompressed files)\n\n## 🔧 Technical Changes\n\n### Code Changes\n- `src/wordTemplateExporter.js`: Enhanced `createCodeBlockXml()` - renders each line separately\n- `src/wordTemplateExporter.js`: Improved `isAsciiArt()` - extended character detection\n- `src/main.js`: Added monofont settings to all PDF export paths\n- `src/main.js`: Enhanced HTML/Electron PDF export CSS\n\n### Key Properties for ASCII Preservation\n```css\npre {\n white-space: pre;\n word-wrap: normal;\n font-family: Consolas, Monaco, ''Courier New'', monospace;\n}\n```\n\n```xml\n<w:pPr>\n <w:keepLines/>\n <w:wordWrap w:val=\"0\"/>\n <w:spacing w:line=\"240\" w:lineRule=\"exact\"/>\n</w:pPr>\n```\n\n## 🔄 Upgrade Notes\n\nIf upgrading from v1.9.0 or earlier:\n- All your settings and preferences will be preserved\n- Recent files list will remain intact\n- Word template selections will be maintained\n- No breaking changes to existing workflows\n\n## 📝 Installation Instructions\n\n### Using the Installer (Recommended)\n1. Download `PanConverter-Setup-1.9.1.exe`\n2. Run the installer\n3. Follow the installation wizard\n4. Launch from Start Menu or Desktop shortcut\n\n### Using Portable Version\n1. Download `PanConverter-1.9.1-x64.exe`\n2. Save to any folder (e.g., Documents, Desktop)\n3. Double-click to run (no installation needed)\n4. Create your own shortcut if desired\n\n## 💬 Feedback\nHave suggestions or found a bug? Please [open an issue](https://github.com/amitwh/pan-converter/issues).\n\n---\n\n**Full Changelog**: https://github.com/amitwh/pan-converter/compare/v1.9.0...v1.9.1\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\" \"dist/PanConverter-1.9.1-x64.exe\" \"dist/PanConverter-1.9.1-x64.zip\" \"dist/PanConverter-Setup-1.9.1.exe\")"
], ],
"deny": [], "deny": [],
"ask": [] "ask": []
+1 -1
View File
@@ -4,7 +4,7 @@
**PanConverter** is a cross-platform Markdown editor and converter powered by Pandoc, built with Electron. It provides professional-grade editing capabilities with comprehensive export options. **PanConverter** is a cross-platform Markdown editor and converter powered by Pandoc, built with Electron. It provides professional-grade editing capabilities with comprehensive export options.
**Current Version**: v1.9.1 **Current Version**: v1.9.2
**Author**: Amit Haridas (amit.wh@gmail.com) **Author**: Amit Haridas (amit.wh@gmail.com)
**License**: MIT **License**: MIT
**Repository**: https://github.com/amitwh/pan-converter **Repository**: https://github.com/amitwh/pan-converter
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "pan-converter", "name": "pan-converter",
"version": "1.9.1", "version": "1.9.2",
"description": "Cross-platform Markdown editor and converter using Pandoc", "description": "Cross-platform Markdown editor and converter using Pandoc",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {
+1 -1
View File
@@ -515,7 +515,7 @@ function createMenu() {
type: 'info', type: 'info',
title: 'About PanConverter', title: 'About PanConverter',
message: 'PanConverter', message: 'PanConverter',
detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.9.1\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Preserved ASCII art, charts, tables, flowcharts in exports (NEW in v1.9.1)\n• Custom Headers & Footers for PDF, DOCX, ODT, and PowerPoint exports\n• Dynamic field support: $PAGE$, $TOTAL$, $DATE$, $TIME$, $TITLE$, $AUTHOR$, $FILENAME$\n• Logo/image embedding in headers and footers\n• Modern glassmorphism UI with gradient backgrounds\n• Enhanced PDF export via Word template with configurable start page\n• Configurable template settings (start page selection)\n• Streamlined PDF Editor UI (merge, split, compress, rotate, watermark, encrypt)\n• Universal File Converter (LibreOffice, ImageMagick, FFmpeg, Pandoc)\n• Windows Explorer context menu integration\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Real-time preview updates while typing\n• Full toolbar markdown editing functions\n• Enhanced PDF export with built-in Electron fallback\n• Enhanced Word export with template support (single file & batch)\n• File association support for .md files\n• Command-line interface for batch conversion\n• Advanced export options with templates and metadata\n• Batch file conversion with progress tracking\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• 22 beautiful themes (including Dracula, Nord, Tokyo Night, Gruvbox, Ayu, Concrete, and more)\n• Undo/redo functionality\n• Live word count and statistics', detail: 'A cross-platform Markdown editor and converter using Pandoc.\n\nVersion: 1.9.2\nAuthor: Amit Haridas\nEmail: amit.wh@gmail.com\nLicense: MIT\n\nFeatures:\n• Preserved ASCII art, charts, tables, flowcharts in exports with full-width background\n• Custom Headers & Footers for PDF, DOCX, ODT, and PowerPoint exports\n• Dynamic field support: $PAGE$, $TOTAL$, $DATE$, $TIME$, $TITLE$, $AUTHOR$, $FILENAME$\n• Logo/image embedding in headers and footers\n• Modern glassmorphism UI with gradient backgrounds\n• Enhanced PDF export via Word template with configurable start page\n• Configurable template settings (start page selection)\n• Streamlined PDF Editor UI (merge, split, compress, rotate, watermark, encrypt)\n• Universal File Converter (LibreOffice, ImageMagick, FFmpeg, Pandoc)\n• Windows Explorer context menu integration\n• Tabbed interface for multiple files\n• Advanced markdown editing with live preview\n• Real-time preview updates while typing\n• Full toolbar markdown editing functions\n• Enhanced PDF export with built-in Electron fallback\n• Enhanced Word export with template support (single file & batch)\n• File association support for .md files\n• Command-line interface for batch conversion\n• Advanced export options with templates and metadata\n• Batch file conversion with progress tracking\n• Improved preview typography and spacing\n• Adjustable font sizes via menu (Ctrl+Shift+Plus/Minus)\n• Complete theme support including Monokai fixes\n• Find & replace with match highlighting\n• Line numbers and auto-indentation\n• Export to multiple formats via Pandoc\n• PowerPoint & presentation export\n• Export tables to Excel/ODS spreadsheets\n• Document import & conversion\n• Table creation helper\n• 22 beautiful themes (including Dracula, Nord, Tokyo Night, Gruvbox, Ayu, Concrete, and more)\n• Undo/redo functionality\n• Live word count and statistics',
buttons: ['OK'] buttons: ['OK']
}); });
} }
+10 -8
View File
@@ -255,6 +255,7 @@ class WordTemplateExporter {
/** /**
* Create code block XML - renders each line as separate paragraph * Create code block XML - renders each line as separate paragraph
* to preserve exact formatting like in preview (monospace, no wrapping) * to preserve exact formatting like in preview (monospace, no wrapping)
* Background shading applied at paragraph level to extend full width
*/ */
createCodeBlockXml(code) { createCodeBlockXml(code) {
const lines = code.split('\n'); const lines = code.split('\n');
@@ -264,10 +265,13 @@ class WordTemplateExporter {
const escapedLine = this.escapeXml(line); const escapedLine = this.escapeXml(line);
// Each line gets its own paragraph with exact spacing and no wrapping // Each line gets its own paragraph with exact spacing and no wrapping
// Shading (shd) is at paragraph level so background extends full width
xml += `<w:p> xml += `<w:p>
<w:pPr> <w:pPr>
<w:pStyle w:val="Normal"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:spacing w:before="${index === 0 ? '120' : '0'}" w:after="${index === lines.length - 1 ? '120' : '0'}" w:line="240" w:lineRule="exact"/> <w:spacing w:before="${index === 0 ? '120' : '0'}" w:after="${index === lines.length - 1 ? '120' : '0'}" w:line="240" w:lineRule="exact"/>
<w:ind w:left="284" w:right="0"/> <w:ind w:left="284" w:right="284"/>
<w:jc w:val="left"/> <w:jc w:val="left"/>
<w:keepLines/> <w:keepLines/>
<w:wordWrap w:val="0"/> <w:wordWrap w:val="0"/>
@@ -277,7 +281,6 @@ class WordTemplateExporter {
<w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/> <w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/>
<w:sz w:val="18"/> <w:sz w:val="18"/>
<w:szCs w:val="18"/> <w:szCs w:val="18"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:noProof/> <w:noProof/>
</w:rPr> </w:rPr>
<w:t xml:space="preserve">${escapedLine}</w:t> <w:t xml:space="preserve">${escapedLine}</w:t>
@@ -457,6 +460,7 @@ class WordTemplateExporter {
/** /**
* Create ASCII art XML with monospace font * Create ASCII art XML with monospace font
* Background shading applied at paragraph level to extend full width
*/ */
createAsciiArtXml(asciiContent) { createAsciiArtXml(asciiContent) {
// Split ASCII art into individual lines and create a paragraph for each // Split ASCII art into individual lines and create a paragraph for each
@@ -464,10 +468,13 @@ class WordTemplateExporter {
let xml = ''; let xml = '';
lines.forEach((line, index) => { lines.forEach((line, index) => {
// Shading (shd) is at paragraph level so background extends full width
xml += `<w:p> xml += `<w:p>
<w:pPr> <w:pPr>
<w:pStyle w:val="Normal"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:spacing w:before="${index === 0 ? '120' : '0'}" w:after="${index === lines.length - 1 ? '120' : '0'}" w:line="240" w:lineRule="exact"/> <w:spacing w:before="${index === 0 ? '120' : '0'}" w:after="${index === lines.length - 1 ? '120' : '0'}" w:line="240" w:lineRule="exact"/>
<w:ind w:left="0" w:right="0"/> <w:ind w:left="284" w:right="284"/>
<w:jc w:val="left"/> <w:jc w:val="left"/>
<w:keepLines/> <w:keepLines/>
<w:wordWrap w:val="0"/> <w:wordWrap w:val="0"/>
@@ -480,7 +487,6 @@ class WordTemplateExporter {
if (hasArrow) { if (hasArrow) {
// Split line into parts and color arrows red // Split line into parts and color arrows red
let remainingLine = line; let remainingLine = line;
let processedText = '';
while (remainingLine.length > 0) { while (remainingLine.length > 0) {
let foundArrow = false; let foundArrow = false;
@@ -506,7 +512,6 @@ class WordTemplateExporter {
<w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/> <w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/>
<w:sz w:val="16"/> <w:sz w:val="16"/>
<w:szCs w:val="16"/> <w:szCs w:val="16"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:noProof/> <w:noProof/>
</w:rPr> </w:rPr>
<w:t xml:space="preserve">${beforeArrow}</w:t> <w:t xml:space="preserve">${beforeArrow}</w:t>
@@ -521,7 +526,6 @@ class WordTemplateExporter {
<w:sz w:val="16"/> <w:sz w:val="16"/>
<w:szCs w:val="16"/> <w:szCs w:val="16"/>
<w:color w:val="FF0000"/> <w:color w:val="FF0000"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:noProof/> <w:noProof/>
</w:rPr> </w:rPr>
<w:t xml:space="preserve">${escapedArrow}</w:t> <w:t xml:space="preserve">${escapedArrow}</w:t>
@@ -537,7 +541,6 @@ class WordTemplateExporter {
<w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/> <w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/>
<w:sz w:val="16"/> <w:sz w:val="16"/>
<w:szCs w:val="16"/> <w:szCs w:val="16"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:noProof/> <w:noProof/>
</w:rPr> </w:rPr>
<w:t xml:space="preserve">${escapedRemaining}</w:t> <w:t xml:space="preserve">${escapedRemaining}</w:t>
@@ -553,7 +556,6 @@ class WordTemplateExporter {
<w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/> <w:rFonts w:ascii="Consolas" w:hAnsi="Consolas" w:cs="Consolas"/>
<w:sz w:val="16"/> <w:sz w:val="16"/>
<w:szCs w:val="16"/> <w:szCs w:val="16"/>
<w:shd w:val="clear" w:color="auto" w:fill="F5F5F5"/>
<w:noProof/> <w:noProof/>
</w:rPr> </w:rPr>
<w:t xml:space="preserve">${escapedLine}</w:t> <w:t xml:space="preserve">${escapedLine}</w:t>