Skip to content

How to automatically use your style.css #23

@ktrns

Description

@ktrns

Dear Felix,

Thank you for providing this repository!

For our bioinformatics work at the DRESDEN-concept Genome Center, we started to write Markdown files to provide READMEs to our collaborators. We are currently using Gitlab for that, and wrote our first CI/CD script to automatically generate HTML and PDF files when a Markdown file has been changed.

The basic pandoc-generated files look pretty ugly, so I started to play around to make them prettier. I followed your recipe today, and ran into a question.

First, I tried pandoc --standalone --css="style.css" (and various versions of it), but it would not incorporate the CSS file properly.

Then, I pretty literally followed your advise and automatically "injected" the content of your style.css file to the end of the basic pandoc-generated HTML file. That worked!

# Convert Markdown to HTML 
pandoc --standalone --from=markdown --to=html $file -o "doc/${id}.html"

# Add CSS at the bottom of the HTML
# Remove last two lines
mv doc/${id}.html doc/${id}_orig.html
head -n -2 doc/${id}_orig.html > doc/${id}.html

# Inject CSS file
echo "<style type='text/css'>" >> doc/${id}.html
cat style.css >> doc/${id}.html

# Close blocks again
echo "</style>" >> doc/${id}.html
echo "</body>" >> doc/${id}.html
echo "</html>" >> doc/${id}.html

It looks so much better than before, but I still wouldn't get the same text width (it looks quite narrow) and am missing the outer border. Would you have any idea?

Thanks a lot in advance!
Best wishes from Dresden :)
Katrin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions