Editorial Workflows

TOC Preview

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: Shows a Markdown preview with an automatically generated table of contents.

Put a "[TOC]" marker on a separate line where you want the table of contents to appear.

Shared by: @olemoritz

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Document Text ?
Folded Text
  • Include
  • Replace with:
Run Python Script ?
Source Code
#coding: utf-8
import workflow
import markdown

action_in = workflow.get_input()

action_out = markdown.markdown(action_in, extensions=['toc'])

Show HTML ?
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Preview</title> <style type="text/css"> body { margin: 0; padding: 0; border: 0; color: #333; font-size: 18px; font-family: "Source Sans Pro", Helvetica, sans-serif; line-height: 150%; vertical-align: baseline; overflow: hidden; background-color: #f6f6f6; } a { color: #337097; text-decoration:none; } h1 { font-size: 27px; margin-top: 32px; margin-bottom: 12px; } h2 { font-size: 24px; margin-top: 32px; margin-bottom: 12px; } h3 { font-size: 22px; } h4, h5, h6 { font-size: 20px; margin-top: 12px; margin-bottom: 0; } h1:first-child { margin-top: 0; } p { margin-bottom: 12px; } p:last-child { margin-bottom:0; } ol { list-style: outside decimal; } ul { list-style: outside disc; } ol, ul { padding-left:0; margin-bottom:12px; } ol li { margin-bottom:16px; margin-left:28px; } ul li { margin-bottom: 12px; margin-left: 20px; } ol:last-child, ul:last-child { margin-bottom:0; } li > p { margin-bottom:12px; } li > ol, li > ul { margin-top: 12px !important; padding-left:12px; } dl { margin-bottom: 12px; } dl dt { font-weight:bold; margin-bottom: 8px; } dl dd { margin-left: 0; margin-bottom: 12px; } dl dd:last-child, dl:last-child { margin-bottom: 0; } pre { white-space: pre-wrap; margin-bottom: 24px; overflow: hidden; padding: 3px; -webkit-border-radius: 3px; background-color: #f6f6f6; border: 1px solid #f3f3f3; } code { font-family: "DejaVuSansMono", monospace; font-size: 0.9em; white-space: nowrap; padding: 2px; -webkit-border-radius: 4px; background-color: #f6f6f6; border: 1px solid #f3f3f3; } pre code { font-family: "DejaVuSansMono", monospace; white-space: pre-wrap; border: none; padding: 0; background-color: transparent; -webkit-border-radius: 0; } blockquote { border-left: 3px solid #ccc; margin-left: 0; margin-right: auto; width: 95%; padding: 0 10px; } table { margin-left: auto; margin-right: auto; margin-bottom: 24px; border-bottom: 1px solid #ddd; border-right: 1px solid #ddd; border-spacing: 0; } table th { padding: 3px 10px; background-color: #f6f6f6; border-top: 1px solid #ddd; border-left: 1px solid #ddd; } table td { padding: 3px 10px; border-top: 1px solid #ddd; border-left: 1px solid #ddd; } img { border: none; display: block; margin: 1em auto; max-width: 100%; } #content-wrapper { height: 100%; overflow-y: scroll; overflow-x: hidden; font-size: 1.0em; width: 100%; } #content { width: auto; padding: 40px 40px 40px 40px; } .footnote { font-size: 0.8em; vertical-align: super; } .footnotes ol { font-weight: bold; } .footnotes ol li p { font-weight: normal; } .toc { border: 1px solid #ccc; border-radius: 4px; background-color: white; padding: 7px; } </style> </head> <body> <div id="content-wrapper"> <div id="content"> Input </div> </div> </body> </html>
Base URL