htmlxhtmlmarkdownmultimarkdown

Multimarkdown well configured header data


Hi I'm trying to get the top of my multimarkdown file to look like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>Test of markdown</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <link rel="stylesheet" type="text/css" href="../main.css" />
    </head>

I know how to add the following metatags:

Title: Test of markdown
CSS: ../main.css
Quotes language: english

which gives me :

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8"/>
        <title>Test of markdown</title>
        <link type="text/css" rel="stylesheet" href="../main.css"/>
    </head>

But I'm not sure how to add the rest. Would appreciate any help. Thanks


Solution

  • I can't find any native markdown way to do this but you could run a little script across the generated HTML if you really feel you need to do this.

    This is a simple Python 3 option that might get you started. This could be improved in many ways but wanted to keep it simple. An obvious idea would be to give it a folder and have it process every HTML file in the folder. But I hope this gives the idea.

    Example code:

    filepath = input('What is the full file path to the file? - ')
    
    htmldoctype = ' '.join([
        '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"',
        '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
        '\n'
    ])
    
    htmlinfo = ('<html xmlns="http://www.w3.org/1999/xhtml">\n')
    
    inlines = []
    
    try:
        with open(filepath, mode='r', encoding='utf-8') as infile:
            for line in infile:
                if line.strip() == '<!DOCTYPE html>':
                    inlines.append(htmldoctype)
                elif line.strip() == '<html>':
                    inlines.append(htmlinfo)
                else:
                    inlines.append(line)
    except Exception:
        print('something went wrong in get')
    
    try:
        with open(filepath, mode='w', encoding='utf-8') as outfile:
            for line in inlines:
                outfile.write(line)
    except Exception:
        print('something went wrong in write')
    

    Input:

        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="utf-8"/>
            <title>Test of markdown</title>
            <link type="text/css" rel="stylesheet" href="../main.css"/>
          </head>
        <body>
            test
        </body>
        </html>
    

    Output:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta charset="utf-8"/>
            <title>Test of markdown</title>
            <link type="text/css" rel="stylesheet" href="../main.css"/>
        </head>
    <body>
      test
    </body>
    </html>