add option to disable prepending of title as # title

This commit is contained in:
Guilhem Fauré 2023-05-24 15:53:49 +02:00
parent e43648ecfa
commit 9c2b66bfc1
2 changed files with 4 additions and 2 deletions

View File

@ -23,6 +23,7 @@ class Configuration:
max_sections_export: int = 500 max_sections_export: int = 500
data_dir: str = "data" data_dir: str = "data"
clear_output: bool = False clear_output: bool = False
prepend_h1: bool = True
def __init__(self, config_file: Optional[str] = None): def __init__(self, config_file: Optional[str] = None):
if config_file is not None: if config_file is not None:

View File

@ -1,10 +1,11 @@
from os.path import basename, splitext from os.path import basename, splitext
from re import I, S, compile from re import I, compile
from peewee import ModelSelect from peewee import ModelSelect
from slugify import slugify from slugify import slugify
from yaml import dump from yaml import dump
from config import config
from converters import convert, link_document from converters import convert, link_document
from database import ( from database import (
SpipArticles, SpipArticles,
@ -105,7 +106,7 @@ class Article(SpipArticles):
def body(self) -> str: def body(self) -> str:
body: str = "" body: str = ""
# Add the title as a Markdown h1 # Add the title as a Markdown h1
if len(self.titre) > 0: if len(self.titre) > 0 and config.prepend_h1:
body += "\n\n# " + self.titre body += "\n\n# " + self.titre
# If there is a text, add the text preceded by two line breaks # If there is a text, add the text preceded by two line breaks
if len(self.texte) > 0: if len(self.texte) > 0: