Although implementations usually get this wrong, Markdown is supposed
to be an extension of HTML; that is, any HTML document is also a
Markdown document. Consequently, you can use cat(1) to convert.

  cat webpage.html > webpage.md

You likely want also to remove some of the HTML tags and use the
Markdown equivalents. This going to suck no matter how you do it because
HTML is involved.

But at least it is pretty short if you use an HTML parser.
Attached is a demonstration in CSS.
/* html5doctor.com Reset v1.6.1 (http://html5doctor.com/html-5-reset-stylesheet/) - http://cssreset.com */
html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}
body{line-height:1}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
nav ul{list-style:none}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:none}
a{margin:0;padding:0;font-size:100%;vertical-align:baseline;background:transparent}
ins{background-color:#ff9;color:#000;text-decoration:none}
mark{background-color:#ff9;color:#000;font-style:italic;font-weight:bold}
del{text-decoration:line-through}
abbr[title],dfn[title]{border-bottom:1px dotted;cursor:help}
table{border-collapse:collapse;border-spacing:0}
hr{display:block;height:1px;border:0;border-top:1px solid #ccc;margin:1em 0;padding:0}
input,select{vertical-align:middle}
/* End reset */

body { position: relative; height: 100%; font-family: monospace; }

h1, h2, h3, h4, h5, h6 { font: inherit; }
h1:before { content: '# ' }
h2:before { content: '## ' }
h3:before { content: '### ' }
h4:before { content: '#### ' }
h5:before { content: '##### ' }

em { font-style: normal; }
em:before { content: '*' }
em:after { content: '*' }

a, a:visited, a:hover, a:active {
  color: inherit;
  text-decoration: inherit;
}
a:before { content: "["; }
a:after { content: "](" attr(href) ")"; }

/* Now rewrite all of the html. */
table, tr { display: block; }
table:before { content: "<table>"; }
table:after { content: "</table>"; }
tr:before { content: "<tr>"; }
tr:after { content: "</tr>"; }
th:before { content: "<th>"; }
th:after { content: "</th>"; }
td:before { content: "<td>"; }
td:after { content: "</td>"; }
dl:before { content: "<dl>"; }
dl:after { content: "</dl>"; }
dd:before { content: "<dd>"; }
dd:after { content: "</dd>"; }
dt:before { content: "<dt>"; }
dt:after { content: "</dt>"; }

Reply via email to