archive
/
md-pdf
Archived
1
Fork 0
This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
md-pdf/md_pdf/build/pandoc.py

26 lines
614 B
Python

import pypandoc
from bs4 import BeautifulSoup
def fix_references_title(content):
soup = BeautifulSoup(content, 'html.parser')
title = soup.new_tag('h1')
title.string = "References"
soup.find('div', class_="references").insert_before(title)
return soup.prettify()
def build_document(files_content):
html = pypandoc.convert_text(files_content, 'html', format='md',
extra_args=[
'-s',
'--bibliography=bib.yml',
'--csl=harvard.csl'
],
filters=[
'pandoc-citeproc'
]
)
return fix_references_title(html)