From 6b5d452123a45494d7774f7441ce9400fdf2e96f Mon Sep 17 00:00:00 2001 From: Naum Spaseski Date: Wed, 10 Dec 2025 03:17:01 +0100 Subject: [PATCH 1/4] Added optional frontmatter header --- config.ini | 39 +++++++++++++++++++++++++++++++++++++++ spec2md.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) diff --git a/config.ini b/config.ini index 8ea8381..402a655 100644 --- a/config.ini +++ b/config.ini @@ -29,6 +29,45 @@ combineCodeParagraphs = true ; Note, that the image caption has follow the image in the document. imageCaptions2AltText = true +; Frontmatter configuration: +; The frontmatter option allows you to replace all content that appears before a specific +; heading in the generated markdown file with custom frontmatter content (such as YAML +; frontmatter for static site generators). This is useful when you want to add metadata, +; title, author information, or other structured content at the beginning of your markdown +; document instead of the original Word document content. +; +; Heading title that marks where frontmatter replacement should occur. +; The frontmatter will replace all content before this heading. The heading should include +; the markdown heading level (e.g., "# " for h1, "## " for h2, etc.). +frontmatterHeading = # Intellectual Property Rights +; +; Frontmatter to replace the content before the heading specified above. +; This can be used to add YAML frontmatter or other content at the start of the document. +; If not specified, the original content before the heading will be kept. +; +; Two ways to specify frontmatter: +; 1. Multiline string (subsequent lines must be indented): +; frontmatter = --- +; frontmatter = title: "Document Title" +; frontmatter = author: "Author Name" +; frontmatter = date: "2025-01-01" +; frontmatter = --- +; +; 2. Read from file (use "file:" prefix): +; frontmatter = file:frontmatter.yaml +; +frontmatter = --- + Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
NFV-MANO procedures specification + Spec Number: NFV-SOL 016 + Version: v5.2.3 + Date: 2025-11 + Release: 5 + Work Item: RGS/NFV-SOL016 + keywords: management, MANO, NFV, procedure + Copyright Year: 2025 + Long ISG Name: Network Functions Virtualisation + Short ISG Name: NFV + --- [toc] ; Add section numbers to the headlines diff --git a/spec2md.py b/spec2md.py index c2f9d58..e464f8c 100644 --- a/spec2md.py +++ b/spec2md.py @@ -153,6 +153,30 @@ class DocumentConfiguration(object): self.skipUnreferencedMediaFiles = config.getboolean('general', 'skipUnreferencedMediaFiles', fallback = False) self.imageCaptions2AltText = config.getboolean('general', 'imageCaptions2AltText', fallback = True) self.combineCodeParagraphs = config.getboolean('general', 'combineCodeParagraphs', fallback = True) + self.frontmatterHeading = config.get('general', 'frontmatterHeading', fallback = None) + + # Frontmatter - can be specified as multiline string or file path + # Note: ConfigParser supports multiline values if subsequent lines are indented + frontmatterConfig = config.get('general', 'frontmatter', fallback = None) + self.frontmatter = None + if frontmatterConfig: + if frontmatterConfig.startswith('file:'): + # Read frontmatter from file + frontmatterFile = frontmatterConfig[5:].strip() + frontmatterPath = Path(frontmatterFile) + if not frontmatterPath.is_absolute(): + # Relative to document directory or config file directory + docDir = os.path.split(documentFileName)[0] + frontmatterPath = Path(docDir) / frontmatterFile + try: + with open(frontmatterPath, 'r', encoding='utf-8') as f: + self.frontmatter = f.read().strip() + except Exception as e: + # Use print instead of _print since _print may not be available during config loading + print(f'Warning: Could not read frontmatter file "{frontmatterPath}": {e}') + else: + # Frontmatter specified directly in config (multiline supported) + self.frontmatter = frontmatterConfig.strip() # Paragraphs self.paragraphs = { c : config.getlist('paragraphs', c) # type: ignore [attr-defined] @@ -1030,6 +1054,27 @@ def processDocuments(documents:list[str], + # + # Replace content before configured heading with frontmatter if configured + # + if docConfig.frontmatter: + # Find the index of the configured heading + iprIndex = None + headingToFind = docConfig.frontmatterHeading.strip() + for i, line in enumerate(lines): + if line.strip() == headingToFind: + iprIndex = i + break + + if iprIndex is not None: + # Replace everything before the IPR section with frontmatter + frontmatterLines = docConfig.frontmatter.split('\n') + lines = frontmatterLines + [''] + lines[iprIndex:] + else: + # If IPR section not found, prepend to the beginning + frontmatterLines = docConfig.frontmatter.split('\n') + lines = frontmatterLines + [''] + lines + # # Write produced Markdown file # -- GitLab From 50f9d7bb20c0ab3b28413fb0b8efe1e53db4575f Mon Sep 17 00:00:00 2001 From: Naum Spaseski Date: Mon, 15 Dec 2025 16:06:42 +0100 Subject: [PATCH 2/4] Added frontmatter config.ini example --- config.ini | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/config.ini b/config.ini index 402a655..fea20f3 100644 --- a/config.ini +++ b/config.ini @@ -57,18 +57,30 @@ frontmatterHeading = # Intellectual Property Rights ; frontmatter = file:frontmatter.yaml ; frontmatter = --- - Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
NFV-MANO procedures specification - Spec Number: NFV-SOL 016 - Version: v5.2.3 + Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
RESTful protocols specification for the Ve-Vnfm Reference Point + Spec Number: NFV-SOL 002 + Version: v5.3.2 Date: 2025-11 Release: 5 - Work Item: RGS/NFV-SOL016 + Work Item: RGS/NFV-SOL002ed541 keywords: management, MANO, NFV, procedure Copyright Year: 2025 Long ISG Name: Network Functions Virtualisation Short ISG Name: NFV --- - +; frontmatter = --- +; Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
NFV-MANO procedures specification +; Spec Number: NFV-SOL 016 +; Version: v5.2.3 +; Date: 2025-11 +; Release: 5 +; Work Item: RGS/NFV-SOL016 +; keywords: management, MANO, NFV, procedure +; Copyright Year: 2025 +; Long ISG Name: Network Functions Virtualisation +; Short ISG Name: NFV +; --- +pandocTableWarnings = false [toc] ; Add section numbers to the headlines addSectionNumbers = false @@ -201,5 +213,5 @@ f0f3 = 266c743b2d3e [media] ; The following configurations specifies the cli command to convert a single .emf file to the.png and .svg image formats. ; If no conversion should or can be done, remove or comment the lines. -emfConverterPng = /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to png "{infile}" --outdir "{outdir}" -emfConverterSvg = /Applications/LibreOffice.app/Contents/MacOS/soffice --headless --convert-to svg "{infile}" --outdir "{outdir}" +emfConverterPng = /usr/bin/soffice --headless --convert-to png "{infile}" --outdir "{outdir}" +emfConverterSvg = /usr/bin/soffice --headless --convert-to svg "{infile}" --outdir "{outdir}" -- GitLab From 676dc301a30d23c1c1b01037e8403d07674ea1b2 Mon Sep 17 00:00:00 2001 From: Miguel Angel Reina Ortega Date: Wed, 17 Dec 2025 11:02:57 +0100 Subject: [PATCH 3/4] Modify frontmatter template --- config.ini | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/config.ini b/config.ini index fea20f3..db29207 100644 --- a/config.ini +++ b/config.ini @@ -57,16 +57,16 @@ frontmatterHeading = # Intellectual Property Rights ; frontmatter = file:frontmatter.yaml ; frontmatter = --- - Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
RESTful protocols specification for the Ve-Vnfm Reference Point - Spec Number: NFV-SOL 002 - Version: v5.3.2 - Date: 2025-11 - Release: 5 - Work Item: RGS/NFV-SOL002ed541 - keywords: management, MANO, NFV, procedure - Copyright Year: 2025 - Long ISG Name: Network Functions Virtualisation - Short ISG Name: NFV + Title: #TITLE# + Spec Number: #SPEC_NUMBER# + Version: #VERSION# + Date: #DATE# + Release: #RELEASE# + Work Item: #WORK-ITEM# + keywords: #KEYWORDS# + Copyright Year: #YEAR# + Long ISG Name: #LONG_ISG# + Short ISG Name: #SHORT_ISG# --- ; frontmatter = --- ; Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
NFV-MANO procedures specification -- GitLab From 13955f93fae33ef58cdb2bbf462f40df6e3efbf3 Mon Sep 17 00:00:00 2001 From: Naum Spaseski Date: Thu, 18 Dec 2025 14:33:50 +0100 Subject: [PATCH 4/4] corrected frontmatter example --- config.ini | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/config.ini b/config.ini index db29207..a3029e0 100644 --- a/config.ini +++ b/config.ini @@ -48,10 +48,9 @@ frontmatterHeading = # Intellectual Property Rights ; Two ways to specify frontmatter: ; 1. Multiline string (subsequent lines must be indented): ; frontmatter = --- -; frontmatter = title: "Document Title" -; frontmatter = author: "Author Name" -; frontmatter = date: "2025-01-01" -; frontmatter = --- +; Title: "Document Title" +; Spec Number: "Author Name" +; --- ; ; 2. Read from file (use "file:" prefix): ; frontmatter = file:frontmatter.yaml @@ -68,18 +67,6 @@ frontmatter = --- Long ISG Name: #LONG_ISG# Short ISG Name: #SHORT_ISG# --- -; frontmatter = --- -; Title: Network Functions Virtualisation (NFV);
Protocols and Data Models;
NFV-MANO procedures specification -; Spec Number: NFV-SOL 016 -; Version: v5.2.3 -; Date: 2025-11 -; Release: 5 -; Work Item: RGS/NFV-SOL016 -; keywords: management, MANO, NFV, procedure -; Copyright Year: 2025 -; Long ISG Name: Network Functions Virtualisation -; Short ISG Name: NFV -; --- pandocTableWarnings = false [toc] ; Add section numbers to the headlines -- GitLab