# Upgrading From Markdeep 1 to 2 Switching a Markdeep 1 document to Markdeep 2 starts with one line at the top and a quick pass over its headers. For most documents, that is the whole upgrade. The sections after Required Changes are optional. In most cases, they are new features that integrate and automate common Markdeep 1 workarounds and styling that the community developed. ## Required Changes Every document needs the first two changes. The others apply only when the document uses the feature they describe, and each of them replaces a Markdeep 1 workaround with something cleaner. ### New Markdeep Line Make the *first* line of your document be the new Markdeep 2 line: ``` <meta charset="utf-8"><script src="markdeep2.min.js" markdeep="2"></script><plaintext> ``` (you can also load it from a local path, of course). Then, delete any markdeep 1 line that is still at the *end* of your document. That is, the Markdeep 1: ``` <!-- Markdeep: --><style class="fallback">...</style><script src="markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script> ``` ### `h1TitleInput` is Now Mandatory If you were already using the Markdeep 1 `markdeepOptions.h1TitleInput = true` setting, you can skip this section. Otherwise: 1. Replace the bold `**Title**` line, and any indented subtitle lines under it, with a single-`#` header: `# Title`. That header is the document title, not a section, and there is exactly one per document. 2. Add one `#` to every other header: `# Section` becomes `## Section`, `## Subsection` becomes `### Subsection`, and so on. Underlined headers are unchanged: `===` is still a level-1 section and `---` a level-2 section. They never become the title. 3. If the document or its style sheet has custom CSS for headers, shift the selectors one level: `.md div.title` becomes `.md h1`, `.md h1` becomes `.md h2`, through `.md h5` becomes `.md h6`. Likewise `.nonumberh1` becomes `.nonumberh2`, and `section.h1-section` becomes `section.h2-section`. ### Adopt New Options 1. If the document assigns `markdeepOptions`, move that script to the top of the file, before the Markdeep line. 2. Delete `h1TitleInput`, `h1TitleOutput`, `enableHiddenLineBreak`, and `enableBackslashLineBreak` options, which are now always true. 3. Drop `?export` and `?noformat` URL parameters. There are lots of new options that you can learn about in the theme manual. ### `document.write` → `markdeep_write` Anywhere you used inline scripts to generate Markdeep content: 1. Change `<script>` → `<script type="generator">`. 2. Change `document.write(text)` → `markdeep_write(text)`. Example: ```html <script type="generator"> markdeep_write('Built on ' + new Date().toDateString() + '.'); </script> ``` ### Put Diagrams in Code Fences If you used the old `*`-fence diagrams, move them to regular code fences with `diagram` class and no border: ````none ```diagram +-----+ +-----+ | A +---->| B | +-----+ +-----+ ``` ```` ### Double Stars Are Italic Markdeep 2 shows `*text*` bold and `**text**` italic, as chat programs do. Where your document means bold, change `**text**` to `*text*`. The [theme manual](../theme/themes-docs.md.html#text/bold_and_italic) shows how to get the CommonMark looks back instead. ## Angle Brackets Work! Markdeep 2 now reads code exactly as written. In code fences and code spans, you can now remove workarounds: 1. Delete `<script type="preformatted">` wrappers and their closing `</script>`. 2. Write C++ and other templates/generics however you wish 3. Change `&lt;` → `<` and `&gt;` → `>`. 4. Delete the space, zero-width space, or backslash after the `<` of `</script>`. ## Hardcoded Paths → `launch.js` If you want, you *can* specify URLs via relative paths or hardcoded to a filesystem or website route. But you may find it much easier to use the new `launch.js` for automatically finding your theme files and `markdeep2.js` no matter how you organize and reorganize your site. ```html <meta charset="utf-8"><script markdeep="2" src="https://morgan3d.github.io/markdeep/2/launch.js?file=my-theme.js"></script><plaintext> ``` will automatically find `my-theme.js` in any parent directory on your own filesystem of the file that loads it. This works for `"https://morgan3d.github.io/markdeep/2/launch.js?file=markdeep2.min.js"` as well, of course. ## Upgrade Your Themes Markdeep 2 JavaScript theme files replace Markdeep 1 JS/CSS templates. They are easier to write and give you more control. The built-in theme also contains the most popular features many people added to their own templates. If you were using an official Markdeep 1 template, find the closest theme (or the default) and switch to it. If you wrote your own custom themes, upgrade them to the format described in the [theme manual](../theme/themes-docs.md.html). ## All Changes The [release history](../../changelog.md.html) lists every change in Markdeep 2.00.