├── .gitignore ├── LICENSE ├── Markingbird-iOS-Demo ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard ├── Info.plist └── ViewController.swift ├── Markingbird-iOS ├── Info.plist └── Markingbird-iOS.h ├── Markingbird.podspec ├── Markingbird.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── Markingbird.xccheckout └── xcshareddata │ └── xcschemes │ ├── Markingbird-iOS.xcscheme │ └── Markingbird.xcscheme ├── Markingbird ├── Info.plist ├── Markdown.swift └── Markingbird.h ├── MarkingbirdTests ├── ConfigTest.swift ├── Info.plist ├── MDTestTests.swift ├── SimpleTests.swift ├── differences.swift └── testfiles │ ├── mdtest-1.1 │ ├── !readme.txt │ ├── Amps_and_angle_encoding.html │ ├── Amps_and_angle_encoding.text │ ├── Auto_links.html │ ├── Auto_links.text │ ├── Backslash_escapes.html │ ├── Backslash_escapes.text │ ├── Blockquotes_with_code_blocks.html │ ├── Blockquotes_with_code_blocks.text │ ├── Code_Blocks.html │ ├── Code_Blocks.text │ ├── Code_Spans.html │ ├── Code_Spans.text │ ├── HTML_comment_edge_case.html │ ├── HTML_comment_edge_case.text │ ├── Hard_wrapped_paragraphs_with_list_like_lines.html │ ├── Hard_wrapped_paragraphs_with_list_like_lines.text │ ├── Horizontal_rules.html │ ├── Horizontal_rules.text │ ├── Images.html │ ├── Images.text │ ├── Inline_HTML_Advanced.html │ ├── Inline_HTML_Advanced.text │ ├── Inline_HTML_Simple.html │ ├── Inline_HTML_Simple.text │ ├── Inline_HTML_comments.html │ ├── Inline_HTML_comments.text │ ├── Links_inline_style.html │ ├── Links_inline_style.text │ ├── Links_reference_style.html │ ├── Links_reference_style.text │ ├── Links_shortcut_references.html │ ├── Links_shortcut_references.text │ ├── Literal_quotes_in_titles.html │ ├── Literal_quotes_in_titles.text │ ├── Markdown_Documentation_Basics.html │ ├── Markdown_Documentation_Basics.text │ ├── Markdown_Documentation_Syntax.html │ ├── Markdown_Documentation_Syntax.text │ ├── Nested_blockquotes.html │ ├── Nested_blockquotes.text │ ├── Ordered_and_unordered_lists.html │ ├── Ordered_and_unordered_lists.text │ ├── Strong_and_em_together.html │ ├── Strong_and_em_together.text │ ├── Tabs.html │ ├── Tabs.text │ ├── Tidyness.html │ └── Tidyness.text │ ├── mstest-0.1 │ ├── !readme.txt │ ├── code-inside-list.html │ ├── code-inside-list.text │ ├── line-endings-cr.html │ ├── line-endings-cr.text │ ├── line-endings-crlf.html │ ├── line-endings-crlf.text │ ├── line-endings-lf.html │ ├── line-endings-lf.text │ ├── markdown-readme.html │ └── markdown-readme.text │ ├── pandoc │ ├── !readme.txt │ ├── failure-to-escape-less-than.html │ ├── failure-to-escape-less-than.text │ ├── indented-code-in-list-item.text │ ├── nested-divs.html │ ├── nested-divs.text │ ├── nested-emphasis.html │ ├── nested-emphasis.text │ ├── unordered-list-and-horizontal-rules.text │ ├── unordered-list-followed-by-ordered-list.text │ └── unpredictable-sublists.text │ └── php-markdown │ ├── !readme.txt │ ├── Backslash escapes.html │ ├── Backslash escapes.text │ ├── Code Spans.html │ ├── Code Spans.text │ ├── Code block in a list item.html │ ├── Code block in a list item.text │ ├── Email auto links.html │ ├── Email auto links.text │ ├── Emphasis.html │ ├── Emphasis.text │ ├── Headers.html │ ├── Headers.text │ ├── Horizontal Rules.html │ ├── Horizontal Rules.text │ ├── Inline HTML (Simple).html │ ├── Inline HTML (Simple).text │ ├── Inline HTML (Span).html │ ├── Inline HTML (Span).text │ ├── Inline HTML comments.html │ ├── Inline HTML comments.text │ ├── Ins & del.html │ ├── Ins & del.text │ ├── Links, inline style.html │ ├── Links, inline style.text │ ├── MD5 Hashes.html │ ├── MD5 Hashes.text │ ├── Nesting.html │ ├── Nesting.text │ ├── PHP-Specific Bugs.html │ ├── PHP-Specific Bugs.text │ ├── Parens in URL.html │ ├── Parens in URL.text │ ├── Tight blocks.html │ └── Tight blocks.text └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | CVS 2 | .#* 3 | 4 | .hg 5 | .hgignore 6 | 7 | .svn 8 | 9 | bin 10 | .bin 11 | Bin 12 | obj 13 | Debug 14 | Debug Dist 15 | Release 16 | Release Dist 17 | TestResults 18 | *.obj 19 | *.suo 20 | *.ncb 21 | *.aps 22 | *.user 23 | *.tli 24 | *.tlh 25 | *.idb 26 | *.pdb 27 | *.tlb 28 | *_i.h 29 | *_h.h 30 | *_i.c 31 | *_p.c 32 | *idl.h 33 | dlldata.c 34 | *ps.dll 35 | *ps.exp 36 | *ps.lib 37 | *.sdf 38 | *.opensdf 39 | ipch 40 | PrecompiledWeb 41 | 42 | build 43 | *.pbxuser 44 | *.perspectivev3 45 | .DS_Store 46 | xcuserdata 47 | *.sublime-project 48 | *.sublime-workspace 49 | 50 | .idea/workspace.xml 51 | .idea/tasks.xml 52 | 53 | *.old 54 | *.log 55 | *.out 56 | *.cache 57 | *.orig 58 | logs 59 | 60 | gen 61 | .metadata 62 | local.properties 63 | 64 | *~ 65 | 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Kristopher Johnson 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | 23 | Markdown.swift is based on MarkdownSharp, which is based on earlier 24 | Markdown implementations. Those implementations' licenses and history 25 | follow. 26 | 27 | 28 | /* 29 | * MarkdownSharp 30 | * ------------- 31 | * a C# Markdown processor 32 | * 33 | * Markdown is a text-to-HTML conversion tool for web writers 34 | * Copyright (c) 2004 John Gruber 35 | * http://daringfireball.net/projects/markdown/ 36 | * 37 | * Markdown.NET 38 | * Copyright (c) 2004-2009 Milan Negovan 39 | * http://www.aspnetresources.com 40 | * http://aspnetresources.com/blog/markdown_announced.aspx 41 | * 42 | * MarkdownSharp 43 | * Copyright (c) 2009-2011 Jeff Atwood 44 | * http://stackoverflow.com 45 | * http://www.codinghorror.com/blog/ 46 | * http://code.google.com/p/markdownsharp/ 47 | * 48 | * History: Milan ported the Markdown processor to C#. He granted license to me so I can open source it 49 | * and let the community contribute to and improve MarkdownSharp. 50 | * 51 | */ 52 | 53 | 54 | Copyright (c) 2009 - 2010 Jeff Atwood 55 | 56 | http://www.opensource.org/licenses/mit-license.php 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining a copy 59 | of this software and associated documentation files (the "Software"), to deal 60 | in the Software without restriction, including without limitation the rights 61 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 62 | copies of the Software, and to permit persons to whom the Software is 63 | furnished to do so, subject to the following conditions: 64 | 65 | The above copyright notice and this permission notice shall be included in 66 | all copies or substantial portions of the Software. 67 | 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 70 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 71 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 72 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 73 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 74 | THE SOFTWARE. 75 | 76 | Copyright (c) 2003-2004 John Gruber 77 | 78 | All rights reserved. 79 | 80 | Redistribution and use in source and binary forms, with or without 81 | modification, are permitted provided that the following conditions are 82 | met: 83 | 84 | * Redistributions of source code must retain the above copyright notice, 85 | this list of conditions and the following disclaimer. 86 | 87 | * Redistributions in binary form must reproduce the above copyright 88 | notice, this list of conditions and the following disclaimer in the 89 | documentation and/or other materials provided with the distribution. 90 | 91 | * Neither the name "Markdown" nor the names of its contributors may 92 | be used to endorse or promote products derived from this software 93 | without specific prior written permission. 94 | 95 | This software is provided by the copyright holders and contributors "as 96 | is" and any express or implied warranties, including, but not limited 97 | to, the implied warranties of merchantability and fitness for a 98 | particular purpose are disclaimed. In no event shall the copyright owner 99 | or contributors be liable for any direct, indirect, incidental, special, 100 | exemplary, or consequential damages (including, but not limited to, 101 | procurement of substitute goods or services; loss of use, data, or 102 | profits; or business interruption) however caused and on any theory of 103 | liability, whether in contract, strict liability, or tort (including 104 | negligence or otherwise) arising in any way out of the use of this 105 | software, even if advised of the possibility of such damage. 106 | 107 | -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // Copyright © 2016 Kristopher Johnson. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | @UIApplicationMain 9 | class AppDelegate: UIResponder, UIApplicationDelegate { 10 | 11 | var window: UIWindow? 12 | 13 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 14 | 15 | return true 16 | } 17 | 18 | func applicationWillResignActive(_ application: UIApplication) { 19 | 20 | } 21 | 22 | func applicationDidEnterBackground(_ application: UIApplication) { 23 | 24 | } 25 | 26 | func applicationWillEnterForeground(_ application: UIApplication) { 27 | 28 | } 29 | 30 | func applicationDidBecomeActive(_ application: UIApplication) { 31 | 32 | } 33 | 34 | func applicationWillTerminate(_ application: UIApplication) { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Markingbird-iOS-Demo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // Copyright © 2016 Kristopher Johnson. All rights reserved. 4 | // 5 | 6 | import UIKit 7 | 8 | class ViewController: UIViewController { 9 | 10 | // MARK: - Properties 11 | 12 | // Internal 13 | 14 | var markdown: Markdown? 15 | 16 | // IBOutlets 17 | 18 | @IBOutlet weak var textView: UITextView! 19 | @IBOutlet weak var webView: UIWebView! 20 | 21 | // MARK: - Lifecycle 22 | 23 | override func viewDidLoad() { 24 | super.viewDidLoad() 25 | 26 | automaticallyAdjustsScrollViewInsets = false 27 | 28 | textView.keyboardDismissMode = .interactive 29 | 30 | var options = MarkdownOptions() 31 | 32 | options.autoHyperlink = true 33 | options.autoNewlines = true 34 | options.emptyElementSuffix = ">" 35 | options.encodeProblemUrlCharacters = true 36 | options.linkEmails = true 37 | options.strictBoldItalic = true 38 | 39 | markdown = Markdown(options: options) 40 | } 41 | 42 | // MARK: Actions 43 | 44 | @IBAction func dismissKeyboard(sender: AnyObject) { 45 | textView.resignFirstResponder() 46 | } 47 | } 48 | 49 | extension ViewController: UITextViewDelegate { 50 | 51 | func textViewDidChange(_ textView: UITextView) { 52 | 53 | if let markdownToHTML = markdown?.transform(textView.text) { 54 | 55 | webView.loadHTMLString(markdownToHTML, baseURL: nil) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Markingbird-iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Markingbird-iOS/Markingbird-iOS.h: -------------------------------------------------------------------------------- 1 | // 2 | // Markingbird-iOS.h 3 | // Markingbird-iOS 4 | // 5 | // Created by Romain Pouclet on 2016-09-03. 6 | // Copyright © 2016 Kristopher Johnson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Markingbird-iOS. 12 | FOUNDATION_EXPORT double Markingbird_iOSVersionNumber; 13 | 14 | //! Project version string for Markingbird-iOS. 15 | FOUNDATION_EXPORT const unsigned char Markingbird_iOSVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Markingbird.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Markingbird" 3 | s.version = "1.13.5" 4 | s.summary = "Markdown processor written in Swift" 5 | 6 | s.description = <<-DESC 7 | Markdown parsing 8 | This library provides a Markdown processor written in Swift for OS X and iOS. It is a translation/port of the MarkdownSharp processor used by Stack Overflow. 9 | DESC 10 | 11 | s.homepage = "https://github.com/kristopherjohnson/Markingbird" 12 | s.license = 'MIT' 13 | s.author = { "Kristopher Johnson" => "@OldManKris" } 14 | s.source = { :git => "git@github.com:kristopherjohnson/Markingbird.git", :tag => s.version.to_s } 15 | s.platform = :ios, '8.0' 16 | s.requires_arc = true 17 | s.tvos.deployment_target = '9.0' 18 | 19 | s.source_files = 'Markingbird/*.{swift}' 20 | end 21 | -------------------------------------------------------------------------------- /Markingbird.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Markingbird.xcodeproj/project.xcworkspace/xcshareddata/Markingbird.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | E8D139E1-4405-4A3B-B3E4-D6F36D4AEC6D 9 | IDESourceControlProjectName 10 | Markingbird 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | F2583FE555E5F9E13F1808DDD493EA57567AC3A5 14 | github.com:kristopherjohnson/Markingbird.git 15 | 16 | IDESourceControlProjectPath 17 | Markingbird.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | F2583FE555E5F9E13F1808DDD493EA57567AC3A5 21 | ../.. 22 | 23 | IDESourceControlProjectURL 24 | github.com:kristopherjohnson/Markingbird.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | F2583FE555E5F9E13F1808DDD493EA57567AC3A5 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | F2583FE555E5F9E13F1808DDD493EA57567AC3A5 36 | IDESourceControlWCCName 37 | Markingbird 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Markingbird.xcodeproj/xcshareddata/xcschemes/Markingbird-iOS.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /Markingbird.xcodeproj/xcshareddata/xcschemes/Markingbird.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Markingbird/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSHumanReadableCopyright 24 | Copyright © 2014 Kristopher Johnson. All rights reserved. 25 | NSPrincipalClass 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Markingbird/Markingbird.h: -------------------------------------------------------------------------------- 1 | // 2 | // Markingbird.h 3 | // Markingbird 4 | // 5 | // Created by Kristopher Johnson on 8/18/14. 6 | // Copyright (c) 2014 Kristopher Johnson. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Markingbird. 12 | FOUNDATION_EXPORT double MarkingbirdVersionNumber; 13 | 14 | //! Project version string for Markingbird. 15 | FOUNDATION_EXPORT const unsigned char MarkingbirdVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /MarkingbirdTests/ConfigTest.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | import Markingbird 3 | 4 | class ConfigTest: XCTestCase { 5 | 6 | func testOptions() { 7 | var options = MarkdownOptions() 8 | options.autoHyperlink = true 9 | options.autoNewlines = true 10 | options.emptyElementSuffix = ">" 11 | options.encodeProblemUrlCharacters = true 12 | options.linkEmails = false 13 | options.strictBoldItalic = true 14 | 15 | var markdown = Markdown(options: options) 16 | XCTAssertEqual(true, markdown.autoHyperlink) 17 | XCTAssertEqual(true, markdown.autoNewLines) 18 | XCTAssertEqual(">", markdown.emptyElementSuffix) 19 | XCTAssertEqual(true, markdown.encodeProblemUrlCharacters) 20 | XCTAssertEqual(false, markdown.linkEmails) 21 | XCTAssertEqual(true, markdown.strictBoldItalic) 22 | } 23 | 24 | func testNoOptions() { 25 | for markdown in [Markdown(), Markdown(options: nil)] { 26 | XCTAssertEqual(false, markdown.autoHyperlink) 27 | XCTAssertEqual(false, markdown.autoNewLines) 28 | XCTAssertEqual(" />", markdown.emptyElementSuffix) 29 | XCTAssertEqual(false, markdown.encodeProblemUrlCharacters) 30 | XCTAssertEqual(true, markdown.linkEmails) 31 | XCTAssertEqual(false, markdown.strictBoldItalic) 32 | } 33 | } 34 | 35 | func testAutoHyperlink() { 36 | var markdown = Markdown() 37 | XCTAssertFalse(markdown.autoHyperlink); 38 | XCTAssertEqual("

foo http://example.com bar

\n", 39 | markdown.transform("foo http://example.com bar")) 40 | 41 | markdown.autoHyperlink = true 42 | XCTAssertEqual("

foo http://example.com bar

\n", 43 | markdown.transform("foo http://example.com bar")) 44 | } 45 | 46 | func testAutoNewLines() { 47 | var markdown = Markdown() 48 | XCTAssertFalse(markdown.autoNewLines) 49 | XCTAssertEqual("

Line1\nLine2

\n", 50 | markdown.transform("Line1\nLine2")) 51 | 52 | markdown.autoNewLines = true 53 | XCTAssertEqual("

Line1
\nLine2

\n", 54 | markdown.transform("Line1\nLine2")) 55 | } 56 | 57 | func testEmptyElementSuffix() { 58 | var markdown = Markdown() 59 | XCTAssertEqual(" />", markdown.emptyElementSuffix) 60 | XCTAssertEqual("
\n", 61 | markdown.transform("* * *")) 62 | 63 | markdown.emptyElementSuffix = ">" 64 | XCTAssertEqual("
\n", markdown.transform("* * *")) 65 | } 66 | 67 | func testEncodeProblemUrlCharacters() { 68 | var markdown = Markdown() 69 | XCTAssertFalse(markdown.encodeProblemUrlCharacters) 70 | XCTAssertEqual("

Foo

\n", 71 | markdown.transform("[Foo](/'*_[]()/)")) 72 | 73 | // Note: MarkdownSharp's test expects '_' to be 74 | // encoded, but that test has apparently not been 75 | // updated to match MarkdownSharp.cs change that 76 | // removed underscore from list of problem characters. 77 | markdown.encodeProblemUrlCharacters = true 78 | XCTAssertEqual("

Foo

\n", 79 | markdown.transform("[Foo](/'*_[]()/)")) 80 | } 81 | 82 | func testLinkEmails() { 83 | var markdown = Markdown() 84 | XCTAssertTrue(markdown.linkEmails) 85 | XCTAssertEqual("

") as NSString).substring(with: NSMakeRange(0, 14))) 87 | 88 | markdown.linkEmails = false 89 | XCTAssertEqual("

\n", markdown.transform("")) 90 | } 91 | 92 | func testStrictBoldItalic() { 93 | var markdown = Markdown() 94 | XCTAssertFalse(markdown.strictBoldItalic) 95 | XCTAssertEqual("

beforeboldafter beforeitalicafter

\n", 96 | markdown.transform("before**bold**after before_italic_after")) 97 | 98 | markdown.strictBoldItalic = true 99 | XCTAssertEqual("

before*bold*after before_italic_after

\n", 100 | markdown.transform("before*bold*after before_italic_after")) 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /MarkingbirdTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /MarkingbirdTests/MDTestTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import XCTest 3 | import Markingbird 4 | 5 | class MDTestTests: XCTestCase { 6 | 7 | let folder = "testfiles/mdtest-1.1" 8 | 9 | /// For each .text file in testfiles/mdtest-1.1, invoke the Markdown transformation 10 | /// and then compare the result with the corresponding .html file 11 | func testTests() { 12 | for test in getTests() { 13 | 14 | // If there is a difference, print it in a more readable way than 15 | // XCTest does 16 | switch firstDifferenceBetweenStrings(test.actualResult, s2: test.expectedResult) { 17 | case .noDifference: 18 | break; 19 | case .differenceAtIndex: 20 | let prettyDiff = prettyFirstDifferenceBetweenStrings(test.actualResult, s2: test.expectedResult) 21 | print("\n====\n\(test.actualName): \(prettyDiff)\n====\n") 22 | } 23 | 24 | XCTAssertEqual(test.actualResult, test.expectedResult, 25 | "Mismatch between '\(test.actualName)' and the transformed '\(test.expectedName)'") 26 | } 27 | } 28 | 29 | struct TestCaseData { 30 | var actualName: String 31 | var expectedName: String 32 | var actualResult: String 33 | var expectedResult: String 34 | 35 | init(actualName: String, expectedName: String, actualResult: String, expectedResult: String) { 36 | self.actualName = actualName 37 | self.expectedName = expectedName 38 | self.actualResult = actualResult 39 | self.expectedResult = expectedResult 40 | } 41 | } 42 | 43 | func getTests() -> [TestCaseData] { 44 | var tests = Array() 45 | 46 | let bundle = Bundle(for: MDTestTests.self) 47 | let resourceURL = bundle.resourceURL! 48 | let folderURL = resourceURL.appendingPathComponent(folder) 49 | 50 | let folderContents: [AnyObject]? 51 | do { 52 | folderContents = try FileManager.default.contentsOfDirectory(atPath: folderURL.path) as [AnyObject]? 53 | } catch { 54 | XCTAssertNil(error) 55 | folderContents = nil 56 | } 57 | XCTAssertNotNil(folderContents) 58 | XCTAssertEqual(49, folderContents!.count, "should find 49 files in the testfiles/mdtest-1.1 directory") 59 | 60 | for object in folderContents! { 61 | if let filename = object as? String { 62 | if filename.hasSuffix(".html") { 63 | // Load the expected result content 64 | let expectedName = filename 65 | 66 | let expectedURL = folderURL.appendingPathComponent(expectedName) 67 | let expectedContent: String? 68 | do { 69 | expectedContent = try String(contentsOfURL: expectedURL, encoding: String.Encoding.utf8) 70 | } catch { 71 | XCTAssertNil(error) 72 | expectedContent = nil 73 | } 74 | 75 | // Load the source content 76 | let actualName = NSURL(string: expectedName)!.deletingPathExtension?.appendingPathExtension("text").path 77 | let sourceURL = folderURL.appendingPathComponent(actualName!) 78 | let sourceContent: String? 79 | do { 80 | sourceContent = try String(contentsOfURL: sourceURL, encoding: String.Encoding.utf8) 81 | } catch { 82 | XCTAssertNil(error) 83 | sourceContent = nil 84 | } 85 | 86 | if sourceContent != nil { 87 | // Transform the source into the actual result, and 88 | // normalize both the actual and expected results 89 | var m = Markdown() 90 | let actualResult = removeWhitespace(m.transform(sourceContent!)) 91 | let expectedResult = removeWhitespace(expectedContent!) 92 | 93 | let testCaseData = TestCaseData( 94 | actualName: actualName!, 95 | expectedName: expectedName, 96 | actualResult: actualResult, 97 | expectedResult: expectedResult) 98 | tests.append(testCaseData) 99 | } 100 | } 101 | } 102 | } 103 | 104 | return tests 105 | } 106 | 107 | /// Removes any empty newlines and any leading spaces at the start of lines 108 | /// all tabs, and all carriage returns 109 | func removeWhitespace(_ s: String) -> String { 110 | var str = s as NSString 111 | 112 | // Standardize line endings 113 | str = str.replacingOccurrences(of: "\r\n", with: "\n") as NSString // DOS to Unix 114 | str = str.replacingOccurrences(of: "\r", with:"\n") as NSString // Mac to Unix 115 | 116 | // remove any tabs entirely 117 | str = str.replacingOccurrences(of: "\t", with: "") as NSString 118 | 119 | // remove empty newlines 120 | let newlineRegex: NSRegularExpression? 121 | do { 122 | newlineRegex = try NSRegularExpression( 123 | pattern: "^\\n", 124 | options: NSRegularExpression.Options.anchorsMatchLines) 125 | } catch { 126 | XCTAssertNil(error) 127 | newlineRegex = nil 128 | } 129 | str = newlineRegex!.stringByReplacingMatches(in: str as String, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, str.length), withTemplate: "") as NSString 130 | 131 | // remove leading space at the start of lines 132 | let leadingSpaceRegex: NSRegularExpression? 133 | do { 134 | leadingSpaceRegex = try NSRegularExpression( 135 | pattern: "^\\s+", 136 | options: NSRegularExpression.Options.anchorsMatchLines) 137 | } catch { 138 | XCTAssertNil(error) 139 | leadingSpaceRegex = nil 140 | }; 141 | str = leadingSpaceRegex!.stringByReplacingMatches(in: str as String, options: NSRegularExpression.MatchingOptions(rawValue: 0), range: NSMakeRange(0, str.length), withTemplate: "") as NSString 142 | 143 | // remove all newlines 144 | str = str.replacingOccurrences(of: "\n", with: "") as NSString 145 | 146 | return str as String 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /MarkingbirdTests/SimpleTests.swift: -------------------------------------------------------------------------------- 1 | import Markingbird 2 | import XCTest 3 | 4 | class SimpleTests: XCTestCase { 5 | 6 | fileprivate var m: Markdown! 7 | 8 | override func setUp() { 9 | // Create a new instance for each test 10 | m = Markdown() 11 | } 12 | 13 | func testBold() 14 | { 15 | let input = "This is **bold**. This is also __bold__." 16 | let expected = "

This is bold. This is also bold.

\n" 17 | 18 | let actual = m.transform(input) 19 | XCTAssertEqual(expected, actual) 20 | } 21 | 22 | func testItalic() 23 | { 24 | let input = "This is *italic*. This is also _italic_." 25 | let expected = "

This is italic. This is also italic.

\n" 26 | 27 | let actual = m.transform(input) 28 | 29 | XCTAssertEqual(expected, actual) 30 | } 31 | 32 | func testLink() 33 | { 34 | let input = "This is [a link][1].\n\n [1]: http://www.example.com" 35 | let expected = "

This is a link.

\n" 36 | 37 | let actual = m.transform(input) 38 | 39 | XCTAssertEqual(expected, actual) 40 | } 41 | 42 | func testLinkBracket() 43 | { 44 | let input = "Have you visited before?" 45 | let expected = "

Have you visited http://www.example.com before?

\n" 46 | 47 | let actual = m.transform(input) 48 | 49 | XCTAssertEqual(expected, actual) 50 | } 51 | 52 | func testLinkBare_withoutAutoHyperLink() 53 | { 54 | let input = "Have you visited http://www.example.com before?" 55 | let expected = "

Have you visited http://www.example.com before?

\n" 56 | 57 | let actual = m.transform(input) 58 | 59 | XCTAssertEqual(expected, actual) 60 | } 61 | 62 | /* 63 | func testLinkBare_withAutoHyperLink() 64 | { 65 | //TODO: implement some way of setting AutoHyperLink programmatically 66 | //to run this test now, just change the _autoHyperlink constant in Markdown.cs 67 | let input = "Have you visited http://www.example.com before?" 68 | let expected = "

Have you visited http://www.example.com before?

\n" 69 | 70 | let actual = m.transform(input) 71 | 72 | XCTAssertEqual(expected, actual) 73 | }*/ 74 | 75 | func testLinkAlt() 76 | { 77 | let input = "Have you visited [example](http://www.example.com) before?" 78 | let expected = "

Have you visited example before?

\n" 79 | 80 | let actual = m.transform(input) 81 | 82 | XCTAssertEqual(expected, actual) 83 | } 84 | 85 | func testImage() 86 | { 87 | let input = "An image goes here: ![alt text][1]\n\n [1]: http://www.google.com/intl/en_ALL/images/logo.gif" 88 | let expected = "

An image goes here: \"alt

\n" 89 | 90 | let actual = m.transform(input) 91 | 92 | XCTAssertEqual(expected, actual) 93 | } 94 | 95 | func testBlockquote() 96 | { 97 | let input = "Here is a quote\n\n> Sample blockquote\n" 98 | let expected = "

Here is a quote

\n\n
\n

Sample blockquote

\n
\n" 99 | 100 | let actual = m.transform(input) 101 | 102 | XCTAssertEqual(expected, actual) 103 | } 104 | 105 | #if true // This test leads to "fatal error: unexpectedly found nil while unwrapping an Optional value 106 | func testNumberList() 107 | { 108 | let input = "A numbered list:\n\n1. a\n2. b\n3. c\n"; 109 | let expected = "

A numbered list:

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n"; 110 | 111 | let actual = m.transform(input) 112 | 113 | XCTAssertEqual(expected, actual) 114 | } 115 | #endif 116 | 117 | func testBulletList() 118 | { 119 | let input = "A bulleted list:\n\n- a\n- b\n- c\n" 120 | let expected = "

A bulleted list:

\n\n
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
\n" 121 | 122 | let actual = m.transform(input) 123 | 124 | XCTAssertEqual(expected, actual) 125 | } 126 | 127 | func testHeader1() 128 | { 129 | let input = "#Header 1\nHeader 1\n========" 130 | let expected = "

Header 1

\n\n

Header 1

\n" 131 | 132 | let actual = m.transform(input) 133 | 134 | XCTAssertEqual(expected, actual) 135 | } 136 | 137 | func testHeader2() 138 | { 139 | let input = "##Header 2\nHeader 2\n--------" 140 | let expected = "

Header 2

\n\n

Header 2

\n" 141 | 142 | let actual = m.transform(input) 143 | 144 | XCTAssertEqual(expected, actual) 145 | } 146 | 147 | func testCodeBlock() 148 | { 149 | let input = "code sample:\n\n \n page title\n \n" 150 | let expected = "

code sample:

\n\n
<head>\n<title>page title</title>\n</head>\n
\n" 151 | 152 | let actual = m.transform(input) 153 | 154 | XCTAssertEqual(expected, actual) 155 | } 156 | 157 | func testCodeSpan() 158 | { 159 | let input = "HTML contains the `` tag" 160 | let expected = "

HTML contains the <blink> tag

\n" 161 | 162 | let actual = m.transform(input) 163 | 164 | XCTAssertEqual(expected, actual) 165 | } 166 | 167 | func testHtmlPassthrough() 168 | { 169 | let input = "
\nHello World!\n
\n" 170 | let expected = "
\nHello World!\n
\n" 171 | 172 | let actual = m.transform(input) 173 | 174 | XCTAssertEqual(expected, actual) 175 | } 176 | 177 | func testEscaping() 178 | { 179 | let input = "\\`foo\\`"; 180 | let expected = "

`foo`

\n" 181 | 182 | let actual = m.transform(input) 183 | 184 | XCTAssertEqual(expected, actual) 185 | } 186 | 187 | func testHorizontalRule() 188 | { 189 | let input = "* * *\n\n***\n\n*****\n\n- - -\n\n---------------------------------------\n\n" 190 | let expected = "
\n\n
\n\n
\n\n
\n\n
\n" 191 | 192 | let actual = m.transform(input) 193 | 194 | XCTAssertEqual(expected, actual) 195 | } 196 | 197 | func testNormalizeCR() 198 | { 199 | let input = "# Header\r\rBody" 200 | let expected = "

Header

\n\n

Body

\n" 201 | 202 | let actual = m.transform(input) 203 | 204 | XCTAssertEqual(expected, actual) 205 | } 206 | 207 | func testNormalizeCRLF() 208 | { 209 | let input = "# Header\r\n\r\nBody" 210 | let expected = "

Header

\n\n

Body

\n" 211 | 212 | let actual = m.transform(input) 213 | 214 | XCTAssertEqual(expected, actual) 215 | } 216 | 217 | func testNormalizeLF() 218 | { 219 | let input = "# Header\n\nBody" 220 | let expected = "

Header

\n\n

Body

\n" 221 | 222 | let actual = m.transform(input) 223 | 224 | XCTAssertEqual(expected, actual) 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /MarkingbirdTests/differences.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | 4 | /// Find first differing character between two strings 5 | /// 6 | /// - parameter s1: First String 7 | /// - parameter s2: Second String 8 | /// 9 | /// - returns: .DifferenceAtIndex(i) or .NoDifference 10 | public func firstDifferenceBetweenStrings(_ s1: NSString, s2: NSString) -> FirstDifferenceResult { 11 | let len1 = s1.length 12 | let len2 = s2.length 13 | 14 | let lenMin = min(len1, len2) 15 | 16 | for i in 0.. NSString { 41 | let firstDifferenceResult = firstDifferenceBetweenStrings(s1, s2: s2) 42 | return prettyDescriptionOfFirstDifferenceResult(firstDifferenceResult, s1: s1, s2: s2) 43 | } 44 | 45 | 46 | /// Create a formatted String representation of a FirstDifferenceResult for two strings 47 | /// 48 | /// - parameter firstDifferenceResult: FirstDifferenceResult 49 | /// - parameter s1: First string used in generation of firstDifferenceResult 50 | /// - parameter s2: Second string used in generation of firstDifferenceResult 51 | /// 52 | /// - returns: a printable string, possibly containing significant whitespace and newlines 53 | public func prettyDescriptionOfFirstDifferenceResult(_ firstDifferenceResult: FirstDifferenceResult, s1: NSString, s2: NSString) -> NSString { 54 | 55 | func diffString(_ index: Int, s1: NSString, s2: NSString) -> NSString { 56 | let markerArrow = "\u{2b06}" // "⬆" 57 | let ellipsis = "\u{2026}" // "…" 58 | 59 | /// Given a string and a range, return a string representing that substring. 60 | /// 61 | /// If the range starts at a position other than 0, an ellipsis 62 | /// will be included at the beginning. 63 | /// 64 | /// If the range ends before the actual end of the string, 65 | /// an ellipsis is added at the end. 66 | func windowSubstring(_ s: NSString, range: NSRange) -> String { 67 | let validRange = NSMakeRange(range.location, min(range.length, s.length - range.location)) 68 | let substring = s.substring(with: validRange) 69 | 70 | let prefix = range.location > 0 ? ellipsis : "" 71 | let suffix = (s.length - range.location > range.length) ? ellipsis : "" 72 | 73 | return "\(prefix)\(substring)\(suffix)" 74 | } 75 | 76 | // Show this many characters before and after the first difference 77 | let windowPrefixLength = 10 78 | let windowSuffixLength = 10 79 | let windowLength = windowPrefixLength + 1 + windowSuffixLength 80 | 81 | let windowIndex = max(index - windowPrefixLength, 0) 82 | let windowRange = NSMakeRange(windowIndex, windowLength) 83 | 84 | let sub1 = windowSubstring(s1, range: windowRange) 85 | let sub2 = windowSubstring(s2, range: windowRange) 86 | 87 | let markerPosition = min(windowSuffixLength, index) + (windowIndex > 0 ? 1 : 0) 88 | 89 | let markerPrefix = String(repeating: " ", count: markerPosition) 90 | let markerLine = "\(markerPrefix)\(markerArrow)" 91 | 92 | return "Difference at index \(index):\n\(sub1)\n\(sub2)\n\(markerLine)" as NSString 93 | } 94 | 95 | switch firstDifferenceResult { 96 | case .noDifference: return "No difference" 97 | case .differenceAtIndex(let index): return diffString(index, s1: s1, s2: s2) 98 | } 99 | } 100 | 101 | 102 | /// Result type for firstDifferenceBetweenStrings() 103 | public enum FirstDifferenceResult { 104 | /// Strings are identical 105 | case noDifference 106 | 107 | /// Strings differ at the specified index. 108 | /// 109 | /// This could mean that characters at the specified index are different, 110 | /// or that one string is longer than the other 111 | case differenceAtIndex(Int) 112 | } 113 | 114 | extension FirstDifferenceResult: CustomStringConvertible, CustomDebugStringConvertible { 115 | /// Textual representation of a FirstDifferenceResult 116 | public var description: String { 117 | switch self { 118 | case .noDifference: 119 | return "NoDifference" 120 | case .differenceAtIndex(let index): 121 | return "DifferenceAtIndex(\(index))" 122 | } 123 | } 124 | 125 | /// Textual representation of a FirstDifferenceResult for debugging purposes 126 | public var debugDescription: String { 127 | return self.description 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/!readme.txt: -------------------------------------------------------------------------------- 1 |  2 | iterates through all the test files in a given folder and generates file-based output 3 | this is essentially the same as running the unit tests, but with diff-able results 4 | 5 | two files should be present for each test: 6 | 7 | test_name.text -- input (raw markdown) 8 | test_name.html -- output (expected cooked html output from reference markdown engine) 9 | 10 | this file will be generated if, and ONLY IF, the expected output does not match the actual output: 11 | 12 | test_name.xxxx.actual.html -- actual output (actual cooked html output from our markdown c# engine) 13 | -- xxxx is the 16-bit CRC checksum of the file contents; this is included 14 | so you can tell if the contents of a failing test have changed 15 | 16 | Contents 17 | ======== 18 | 19 | this is the closest thing to a set of Markdown reference tests I could find 20 | 21 | see http://six.pairlist.net/pipermail/markdown-discuss/2009-February/001526.html 22 | and http://michelf.com/docs/projets/mdtest-1.1.zip 23 | and http://git.michelf.com/mdtest/ -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Amps_and_angle_encoding.html: -------------------------------------------------------------------------------- 1 |

AT&T has an ampersand in their name.

2 | 3 |

AT&T is another way to write it.

4 | 5 |

This & that.

6 | 7 |

4 < 5.

8 | 9 |

6 > 5.

10 | 11 |

Here's a link with an ampersand in the URL.

12 | 13 |

Here's a link with an amersand in the link text: AT&T.

14 | 15 |

Here's an inline link.

16 | 17 |

Here's an inline link.

18 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Amps_and_angle_encoding.text: -------------------------------------------------------------------------------- 1 | AT&T has an ampersand in their name. 2 | 3 | AT&T is another way to write it. 4 | 5 | This & that. 6 | 7 | 4 < 5. 8 | 9 | 6 > 5. 10 | 11 | Here's a [link] [1] with an ampersand in the URL. 12 | 13 | Here's a link with an amersand in the link text: [AT&T] [2]. 14 | 15 | Here's an inline [link](/script?foo=1&bar=2). 16 | 17 | Here's an inline [link](). 18 | 19 | 20 | [1]: http://example.com/?foo=1&bar=2 21 | [2]: http://att.com/ "AT&T" -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Auto_links.html: -------------------------------------------------------------------------------- 1 |

Link: http://example.com/.

2 | 3 |

With an ampersand: http://example.com/?foo=1&bar=2

4 | 5 | 10 | 11 |
12 |

Blockquoted: http://example.com/

13 |
14 | 15 |

Auto-links should not occur here: <http://example.com/>

16 | 17 |
or here: <http://example.com/>
18 | 
19 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Auto_links.text: -------------------------------------------------------------------------------- 1 | Link: . 2 | 3 | With an ampersand: 4 | 5 | * In a list? 6 | * 7 | * It should. 8 | 9 | > Blockquoted: 10 | 11 | Auto-links should not occur here: `` 12 | 13 | or here: -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Backslash_escapes.html: -------------------------------------------------------------------------------- 1 |

These should all get escaped:

2 | 3 |

Backslash: \

4 | 5 |

Backtick: `

6 | 7 |

Asterisk: *

8 | 9 |

Underscore: _

10 | 11 |

Left brace: {

12 | 13 |

Right brace: }

14 | 15 |

Left bracket: [

16 | 17 |

Right bracket: ]

18 | 19 |

Left paren: (

20 | 21 |

Right paren: )

22 | 23 |

Greater-than: >

24 | 25 |

Hash: #

26 | 27 |

Period: .

28 | 29 |

Bang: !

30 | 31 |

Plus: +

32 | 33 |

Minus: -

34 | 35 |

These should not, because they occur within a code block:

36 | 37 |
Backslash: \\
 38 | 
 39 | Backtick: \`
 40 | 
 41 | Asterisk: \*
 42 | 
 43 | Underscore: \_
 44 | 
 45 | Left brace: \{
 46 | 
 47 | Right brace: \}
 48 | 
 49 | Left bracket: \[
 50 | 
 51 | Right bracket: \]
 52 | 
 53 | Left paren: \(
 54 | 
 55 | Right paren: \)
 56 | 
 57 | Greater-than: \>
 58 | 
 59 | Hash: \#
 60 | 
 61 | Period: \.
 62 | 
 63 | Bang: \!
 64 | 
 65 | Plus: \+
 66 | 
 67 | Minus: \-
 68 | 
69 | 70 |

Nor should these, which occur in code spans:

71 | 72 |

Backslash: \\

73 | 74 |

Backtick: \`

75 | 76 |

Asterisk: \*

77 | 78 |

Underscore: \_

79 | 80 |

Left brace: \{

81 | 82 |

Right brace: \}

83 | 84 |

Left bracket: \[

85 | 86 |

Right bracket: \]

87 | 88 |

Left paren: \(

89 | 90 |

Right paren: \)

91 | 92 |

Greater-than: \>

93 | 94 |

Hash: \#

95 | 96 |

Period: \.

97 | 98 |

Bang: \!

99 | 100 |

Plus: \+

101 | 102 |

Minus: \-

103 | 104 | 105 |

These should get escaped, even though they're matching pairs for 106 | other Markdown constructs:

107 | 108 |

*asterisks*

109 | 110 |

_underscores_

111 | 112 |

`backticks`

113 | 114 |

This is a code span with a literal backslash-backtick sequence: \`

115 | 116 |

This is a tag with unescaped backticks bar.

117 | 118 |

This is a tag with backslashes bar.

119 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Backslash_escapes.text: -------------------------------------------------------------------------------- 1 | These should all get escaped: 2 | 3 | Backslash: \\ 4 | 5 | Backtick: \` 6 | 7 | Asterisk: \* 8 | 9 | Underscore: \_ 10 | 11 | Left brace: \{ 12 | 13 | Right brace: \} 14 | 15 | Left bracket: \[ 16 | 17 | Right bracket: \] 18 | 19 | Left paren: \( 20 | 21 | Right paren: \) 22 | 23 | Greater-than: \> 24 | 25 | Hash: \# 26 | 27 | Period: \. 28 | 29 | Bang: \! 30 | 31 | Plus: \+ 32 | 33 | Minus: \- 34 | 35 | 36 | 37 | These should not, because they occur within a code block: 38 | 39 | Backslash: \\ 40 | 41 | Backtick: \` 42 | 43 | Asterisk: \* 44 | 45 | Underscore: \_ 46 | 47 | Left brace: \{ 48 | 49 | Right brace: \} 50 | 51 | Left bracket: \[ 52 | 53 | Right bracket: \] 54 | 55 | Left paren: \( 56 | 57 | Right paren: \) 58 | 59 | Greater-than: \> 60 | 61 | Hash: \# 62 | 63 | Period: \. 64 | 65 | Bang: \! 66 | 67 | Plus: \+ 68 | 69 | Minus: \- 70 | 71 | 72 | Nor should these, which occur in code spans: 73 | 74 | Backslash: `\\` 75 | 76 | Backtick: `` \` `` 77 | 78 | Asterisk: `\*` 79 | 80 | Underscore: `\_` 81 | 82 | Left brace: `\{` 83 | 84 | Right brace: `\}` 85 | 86 | Left bracket: `\[` 87 | 88 | Right bracket: `\]` 89 | 90 | Left paren: `\(` 91 | 92 | Right paren: `\)` 93 | 94 | Greater-than: `\>` 95 | 96 | Hash: `\#` 97 | 98 | Period: `\.` 99 | 100 | Bang: `\!` 101 | 102 | Plus: `\+` 103 | 104 | Minus: `\-` 105 | 106 | 107 | These should get escaped, even though they're matching pairs for 108 | other Markdown constructs: 109 | 110 | \*asterisks\* 111 | 112 | \_underscores\_ 113 | 114 | \`backticks\` 115 | 116 | This is a code span with a literal backslash-backtick sequence: `` \` `` 117 | 118 | This is a tag with unescaped backticks bar. 119 | 120 | This is a tag with backslashes bar. 121 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Blockquotes_with_code_blocks.html: -------------------------------------------------------------------------------- 1 |
2 |

Example:

3 | 4 |
sub status {
 5 |     print "working";
 6 | }
 7 | 
8 | 9 |

Or:

10 | 11 |
sub status {
12 |     return "working";
13 | }
14 | 
15 |
16 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Blockquotes_with_code_blocks.text: -------------------------------------------------------------------------------- 1 | > Example: 2 | > 3 | > sub status { 4 | > print "working"; 5 | > } 6 | > 7 | > Or: 8 | > 9 | > sub status { 10 | > return "working"; 11 | > } 12 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Code_Blocks.html: -------------------------------------------------------------------------------- 1 |
code block on the first line
 2 | 
3 | 4 |

Regular text.

5 | 6 |
code block indented by spaces
 7 | 
8 | 9 |

Regular text.

10 | 11 |
the lines in this block  
12 | all contain trailing spaces  
13 | 
14 | 15 |

Regular Text.

16 | 17 |
code block on the last line
18 | 
19 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Code_Blocks.text: -------------------------------------------------------------------------------- 1 | code block on the first line 2 | 3 | Regular text. 4 | 5 | code block indented by spaces 6 | 7 | Regular text. 8 | 9 | the lines in this block 10 | all contain trailing spaces 11 | 12 | Regular Text. 13 | 14 | code block on the last line -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Code_Spans.html: -------------------------------------------------------------------------------- 1 |

<test a=" content of attribute ">

2 | 3 |

Fix for backticks within HTML tag: like this

4 | 5 |

Here's how you put `backticks` in a code span.

6 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Code_Spans.text: -------------------------------------------------------------------------------- 1 | `` 2 | 3 | Fix for backticks within HTML tag: like this 4 | 5 | Here's how you put `` `backticks` `` in a code span. -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/HTML_comment_edge_case.html: -------------------------------------------------------------------------------- 1 |

Here is text. 2 | 3 | This is more text.

4 | 5 |
    6 |
  • Markdown
  • 7 |
  • formatting
  • 8 |
9 | 10 | 11 | 12 |

Even more text.

13 | 14 |
    15 |
  1. abc 16 |

  2. 17 |
  3. def

  4. 18 |
19 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/HTML_comment_edge_case.text: -------------------------------------------------------------------------------- 1 | Here is text. 2 | 3 | This is more text. 4 | 5 | * Markdown 6 | * formatting 7 | 8 | 9 | 10 | Even more text. 11 | 12 | 1. abc 13 | 14 | 15 | 2. def -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Hard_wrapped_paragraphs_with_list_like_lines.html: -------------------------------------------------------------------------------- 1 |

In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item.

6 | 7 |

Here's one with a bullet. 8 | * criminey.

9 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Hard_wrapped_paragraphs_with_list_like_lines.text: -------------------------------------------------------------------------------- 1 | In Markdown 1.0.0 and earlier. Version 2 | 8. This line turns into a list item. 3 | Because a hard-wrapped line in the 4 | middle of a paragraph looked like a 5 | list item. 6 | 7 | Here's one with a bullet. 8 | * criminey. 9 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Horizontal_rules.html: -------------------------------------------------------------------------------- 1 |

Dashes:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
---
12 | 
13 | 14 |
15 | 16 |
17 | 18 |
19 | 20 |
21 | 22 |
- - -
23 | 
24 | 25 |

Asterisks:

26 | 27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 | 35 |
***
36 | 
37 | 38 |
39 | 40 |
41 | 42 |
43 | 44 |
45 | 46 |
* * *
47 | 
48 | 49 |

Underscores:

50 | 51 |
52 | 53 |
54 | 55 |
56 | 57 |
58 | 59 |
___
60 | 
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
_ _ _
71 | 
72 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Horizontal_rules.text: -------------------------------------------------------------------------------- 1 | Dashes: 2 | 3 | --- 4 | 5 | --- 6 | 7 | --- 8 | 9 | --- 10 | 11 | --- 12 | 13 | - - - 14 | 15 | - - - 16 | 17 | - - - 18 | 19 | - - - 20 | 21 | - - - 22 | 23 | 24 | Asterisks: 25 | 26 | *** 27 | 28 | *** 29 | 30 | *** 31 | 32 | *** 33 | 34 | *** 35 | 36 | * * * 37 | 38 | * * * 39 | 40 | * * * 41 | 42 | * * * 43 | 44 | * * * 45 | 46 | 47 | Underscores: 48 | 49 | ___ 50 | 51 | ___ 52 | 53 | ___ 54 | 55 | ___ 56 | 57 | ___ 58 | 59 | _ _ _ 60 | 61 | _ _ _ 62 | 63 | _ _ _ 64 | 65 | _ _ _ 66 | 67 | _ _ _ 68 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Images.html: -------------------------------------------------------------------------------- 1 |

Alt text

2 | 3 |

Alt text

4 | 5 |

Inline within a paragraph: alt text.

6 | 7 |

alt text

8 | 9 |

alt text

10 | 11 |

alt text

12 | 13 |

alt text.

14 | 15 |

Empty

16 | 17 |

this is a stupid URL

18 | 19 |

alt text

20 | 21 |

alt text

22 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Images.text: -------------------------------------------------------------------------------- 1 | ![Alt text](/path/to/img.jpg) 2 | 3 | ![Alt text](/path/to/img.jpg "Optional title") 4 | 5 | Inline within a paragraph: [alt text](/url/). 6 | 7 | ![alt text](/url/ "title preceded by two spaces") 8 | 9 | ![alt text](/url/ "title has spaces afterward" ) 10 | 11 | ![alt text]() 12 | 13 | ![alt text]( "with a title"). 14 | 15 | ![Empty]() 16 | 17 | ![this is a stupid URL](http://example.com/(parens).jpg) 18 | 19 | 20 | ![alt text][foo] 21 | 22 | [foo]: /url/ 23 | 24 | ![alt text][bar] 25 | 26 | [bar]: /url/ "Title here" -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_Advanced.html: -------------------------------------------------------------------------------- 1 |

Simple block on one line:

2 | 3 |
foo
4 | 5 |

And nested without indentation:

6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | 17 |

And with attributes:

18 | 19 |
20 |
21 |
22 |
23 | 24 |

This was broken in 1.0.2b7:

25 | 26 |
27 |
28 | foo 29 |
30 |
31 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_Advanced.text: -------------------------------------------------------------------------------- 1 | Simple block on one line: 2 | 3 |
foo
4 | 5 | And nested without indentation: 6 | 7 |
8 |
9 |
10 | foo 11 |
12 |
13 |
14 |
bar
15 |
16 | 17 | And with attributes: 18 | 19 |
20 |
21 |
22 |
23 | 24 | This was broken in 1.0.2b7: 25 | 26 |
27 |
28 | foo 29 |
30 |
31 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_Simple.html: -------------------------------------------------------------------------------- 1 |

Here's a simple block:

2 | 3 |
4 | foo 5 |
6 | 7 |

This should be a code block, though:

8 | 9 |
<div>
10 |     foo
11 | </div>
12 | 
13 | 14 |

As should this:

15 | 16 |
<div>foo</div>
17 | 
18 | 19 |

Now, nested:

20 | 21 |
22 |
23 |
24 | foo 25 |
26 |
27 |
28 | 29 |

This should just be an HTML comment:

30 | 31 | 32 | 33 |

Multiline:

34 | 35 | 39 | 40 |

Code block:

41 | 42 |
<!-- Comment -->
43 | 
44 | 45 |

Just plain comment, with trailing spaces on the line:

46 | 47 | 48 | 49 |

Code:

50 | 51 |
<hr />
52 | 
53 | 54 |

Hr's:

55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 |
71 | 72 |
73 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_Simple.text: -------------------------------------------------------------------------------- 1 | Here's a simple block: 2 | 3 |
4 | foo 5 |
6 | 7 | This should be a code block, though: 8 | 9 |
10 | foo 11 |
12 | 13 | As should this: 14 | 15 |
foo
16 | 17 | Now, nested: 18 | 19 |
20 |
21 |
22 | foo 23 |
24 |
25 |
26 | 27 | This should just be an HTML comment: 28 | 29 | 30 | 31 | Multiline: 32 | 33 | 37 | 38 | Code block: 39 | 40 | 41 | 42 | Just plain comment, with trailing spaces on the line: 43 | 44 | 45 | 46 | Code: 47 | 48 |
49 | 50 | Hr's: 51 | 52 |
53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 |
61 | 62 |
63 | 64 |
65 | 66 |
67 | 68 |
69 | 70 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 | 8 | 9 |

Paragraph two.

10 | 11 |

12 | 13 |

The end.

14 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Inline_HTML_comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | 8 | 9 | Paragraph two. 10 | 11 | 12 | 13 | The end. 14 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_inline_style.html: -------------------------------------------------------------------------------- 1 |

Just a URL.

2 | 3 |

URL and title.

4 | 5 |

URL and title.

6 | 7 |

URL and title.

8 | 9 |

URL and title.

10 | 11 |

URL wrapped in angle brackets.

12 | 13 |

URL w/ angle brackets + title.

14 | 15 |

Empty.

16 | 17 |

With parens in the URL

18 | 19 |

(With outer parens and parens in url)

20 | 21 |

With parens in the URL

22 | 23 |

(With outer parens and parens in url)

24 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_inline_style.text: -------------------------------------------------------------------------------- 1 | Just a [URL](/url/). 2 | 3 | [URL and title](/url/ "title"). 4 | 5 | [URL and title](/url/ "title preceded by two spaces"). 6 | 7 | [URL and title](/url/ "title preceded by a tab"). 8 | 9 | [URL and title](/url/ "title has spaces afterward" ). 10 | 11 | [URL wrapped in angle brackets](). 12 | 13 | [URL w/ angle brackets + title]( "Here's the title"). 14 | 15 | [Empty](). 16 | 17 | [With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing)) 18 | 19 | (With outer parens and [parens in url](/foo(bar))) 20 | 21 | 22 | [With parens in the URL](/foo(bar) "and a title") 23 | 24 | (With outer parens and [parens in url](/foo(bar) "and a title")) 25 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_reference_style.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | 5 |

Foo bar.

6 | 7 |

With embedded [brackets].

8 | 9 |

Indented once.

10 | 11 |

Indented twice.

12 | 13 |

Indented thrice.

14 | 15 |

Indented [four][] times.

16 | 17 |
[four]: /url
18 | 
19 | 20 |
21 | 22 |

this should work

23 | 24 |

So should this.

25 | 26 |

And this.

27 | 28 |

And this.

29 | 30 |

And this.

31 | 32 |

But not [that] [].

33 | 34 |

Nor [that][].

35 | 36 |

Nor [that].

37 | 38 |

[Something in brackets like this should work]

39 | 40 |

[Same with this.]

41 | 42 |

In this case, this points to something else.

43 | 44 |

Backslashing should suppress [this] and [this].

45 | 46 |
47 | 48 |

Here's one where the link 49 | breaks across lines.

50 | 51 |

Here's another where the link 52 | breaks across lines, but with a line-ending space.

53 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_reference_style.text: -------------------------------------------------------------------------------- 1 | Foo [bar] [1]. 2 | 3 | Foo [bar][1]. 4 | 5 | Foo [bar] 6 | [1]. 7 | 8 | [1]: /url/ "Title" 9 | 10 | 11 | With [embedded [brackets]] [b]. 12 | 13 | 14 | Indented [once][]. 15 | 16 | Indented [twice][]. 17 | 18 | Indented [thrice][]. 19 | 20 | Indented [four][] times. 21 | 22 | [once]: /url 23 | 24 | [twice]: /url 25 | 26 | [thrice]: /url 27 | 28 | [four]: /url 29 | 30 | 31 | [b]: /url/ 32 | 33 | * * * 34 | 35 | [this] [this] should work 36 | 37 | So should [this][this]. 38 | 39 | And [this] []. 40 | 41 | And [this][]. 42 | 43 | And [this]. 44 | 45 | But not [that] []. 46 | 47 | Nor [that][]. 48 | 49 | Nor [that]. 50 | 51 | [Something in brackets like [this][] should work] 52 | 53 | [Same with [this].] 54 | 55 | In this case, [this](/somethingelse/) points to something else. 56 | 57 | Backslashing should suppress \[this] and [this\]. 58 | 59 | [this]: foo 60 | 61 | 62 | * * * 63 | 64 | Here's one where the [link 65 | breaks] across lines. 66 | 67 | Here's another where the [link 68 | breaks] across lines, but with a line-ending space. 69 | 70 | 71 | [link breaks]: /url/ 72 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_shortcut_references.html: -------------------------------------------------------------------------------- 1 |

This is the simple case.

2 | 3 |

This one has a line 4 | break.

5 | 6 |

This one has a line 7 | break with a line-ending space.

8 | 9 |

this and the other

10 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Links_shortcut_references.text: -------------------------------------------------------------------------------- 1 | This is the [simple case]. 2 | 3 | [simple case]: /simple 4 | 5 | 6 | 7 | This one has a [line 8 | break]. 9 | 10 | This one has a [line 11 | break] with a line-ending space. 12 | 13 | [line break]: /foo 14 | 15 | 16 | [this] [that] and the [other] 17 | 18 | [this]: /this 19 | [that]: /that 20 | [other]: /other 21 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Literal_quotes_in_titles.html: -------------------------------------------------------------------------------- 1 |

Foo bar.

2 | 3 |

Foo bar.

4 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Literal_quotes_in_titles.text: -------------------------------------------------------------------------------- 1 | Foo [bar][]. 2 | 3 | Foo [bar](/url/ "Title with "quotes" inside"). 4 | 5 | 6 | [bar]: /url/ "Title with "quotes" inside" 7 | 8 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Markdown_Documentation_Basics.html: -------------------------------------------------------------------------------- 1 |

Markdown: Basics

2 | 3 | 10 | 11 |

Getting the Gist of Markdown's Formatting Syntax

12 | 13 |

This page offers a brief overview of what it's like to use Markdown. 14 | The syntax page provides complete, detailed documentation for 15 | every feature, but Markdown should be very easy to pick up simply by 16 | looking at a few examples of it in action. The examples on this page 17 | are written in a before/after style, showing example syntax and the 18 | HTML output produced by Markdown.

19 | 20 |

It's also helpful to simply try Markdown out; the Dingus is a 21 | web application that allows you type your own Markdown-formatted text 22 | and translate it to XHTML.

23 | 24 |

Note: This document is itself written using Markdown; you 25 | can see the source for it by adding '.text' to the URL.

26 | 27 |

Paragraphs, Headers, Blockquotes

28 | 29 |

A paragraph is simply one or more consecutive lines of text, separated 30 | by one or more blank lines. (A blank line is any line that looks like a 31 | blank line -- a line containing nothing spaces or tabs is considered 32 | blank.) Normal paragraphs should not be intended with spaces or tabs.

33 | 34 |

Markdown offers two styles of headers: Setext and atx. 35 | Setext-style headers for <h1> and <h2> are created by 36 | "underlining" with equal signs (=) and hyphens (-), respectively. 37 | To create an atx-style header, you put 1-6 hash marks (#) at the 38 | beginning of the line -- the number of hashes equals the resulting 39 | HTML header level.

40 | 41 |

Blockquotes are indicated using email-style '>' angle brackets.

42 | 43 |

Markdown:

44 | 45 |
A First Level Header
 46 | ====================
 47 | 
 48 | A Second Level Header
 49 | ---------------------
 50 | 
 51 | Now is the time for all good men to come to
 52 | the aid of their country. This is just a
 53 | regular paragraph.
 54 | 
 55 | The quick brown fox jumped over the lazy
 56 | dog's back.
 57 | 
 58 | ### Header 3
 59 | 
 60 | > This is a blockquote.
 61 | > 
 62 | > This is the second paragraph in the blockquote.
 63 | >
 64 | > ## This is an H2 in a blockquote
 65 | 
66 | 67 |

Output:

68 | 69 |
<h1>A First Level Header</h1>
 70 | 
 71 | <h2>A Second Level Header</h2>
 72 | 
 73 | <p>Now is the time for all good men to come to
 74 | the aid of their country. This is just a
 75 | regular paragraph.</p>
 76 | 
 77 | <p>The quick brown fox jumped over the lazy
 78 | dog's back.</p>
 79 | 
 80 | <h3>Header 3</h3>
 81 | 
 82 | <blockquote>
 83 |     <p>This is a blockquote.</p>
 84 | 
 85 |     <p>This is the second paragraph in the blockquote.</p>
 86 | 
 87 |     <h2>This is an H2 in a blockquote</h2>
 88 | </blockquote>
 89 | 
90 | 91 |

Phrase Emphasis

92 | 93 |

Markdown uses asterisks and underscores to indicate spans of emphasis.

94 | 95 |

Markdown:

96 | 97 |
Some of these words *are emphasized*.
 98 | Some of these words _are emphasized also_.
 99 | 
100 | Use two asterisks for **strong emphasis**.
101 | Or, if you prefer, __use two underscores instead__.
102 | 
103 | 104 |

Output:

105 | 106 |
<p>Some of these words <em>are emphasized</em>.
107 | Some of these words <em>are emphasized also</em>.</p>
108 | 
109 | <p>Use two asterisks for <strong>strong emphasis</strong>.
110 | Or, if you prefer, <strong>use two underscores instead</strong>.</p>
111 | 
112 | 113 |

Lists

114 | 115 |

Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, 116 | +, and -) as list markers. These three markers are 117 | interchangable; this:

118 | 119 |
*   Candy.
120 | *   Gum.
121 | *   Booze.
122 | 
123 | 124 |

this:

125 | 126 |
+   Candy.
127 | +   Gum.
128 | +   Booze.
129 | 
130 | 131 |

and this:

132 | 133 |
-   Candy.
134 | -   Gum.
135 | -   Booze.
136 | 
137 | 138 |

all produce the same output:

139 | 140 |
<ul>
141 | <li>Candy.</li>
142 | <li>Gum.</li>
143 | <li>Booze.</li>
144 | </ul>
145 | 
146 | 147 |

Ordered (numbered) lists use regular numbers, followed by periods, as 148 | list markers:

149 | 150 |
1.  Red
151 | 2.  Green
152 | 3.  Blue
153 | 
154 | 155 |

Output:

156 | 157 |
<ol>
158 | <li>Red</li>
159 | <li>Green</li>
160 | <li>Blue</li>
161 | </ol>
162 | 
163 | 164 |

If you put blank lines between items, you'll get <p> tags for the 165 | list item text. You can create multi-paragraph list items by indenting 166 | the paragraphs by 4 spaces or 1 tab:

167 | 168 |
*   A list item.
169 | 
170 |     With multiple paragraphs.
171 | 
172 | *   Another item in the list.
173 | 
174 | 175 |

Output:

176 | 177 |
<ul>
178 | <li><p>A list item.</p>
179 | <p>With multiple paragraphs.</p></li>
180 | <li><p>Another item in the list.</p></li>
181 | </ul>
182 | 
183 | 184 |

Links

185 | 186 |

Markdown supports two styles for creating links: inline and 187 | reference. With both styles, you use square brackets to delimit the 188 | text you want to turn into a link.

189 | 190 |

Inline-style links use parentheses immediately after the link text. 191 | For example:

192 | 193 |
This is an [example link](http://example.com/).
194 | 
195 | 196 |

Output:

197 | 198 |
<p>This is an <a href="http://example.com/">
199 | example link</a>.</p>
200 | 
201 | 202 |

Optionally, you may include a title attribute in the parentheses:

203 | 204 |
This is an [example link](http://example.com/ "With a Title").
205 | 
206 | 207 |

Output:

208 | 209 |
<p>This is an <a href="http://example.com/" title="With a Title">
210 | example link</a>.</p>
211 | 
212 | 213 |

Reference-style links allow you to refer to your links by names, which 214 | you define elsewhere in your document:

215 | 216 |
I get 10 times more traffic from [Google][1] than from
217 | [Yahoo][2] or [MSN][3].
218 | 
219 | [1]: http://google.com/        "Google"
220 | [2]: http://search.yahoo.com/  "Yahoo Search"
221 | [3]: http://search.msn.com/    "MSN Search"
222 | 
223 | 224 |

Output:

225 | 226 |
<p>I get 10 times more traffic from <a href="http://google.com/"
227 | title="Google">Google</a> than from <a href="http://search.yahoo.com/"
228 | title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/"
229 | title="MSN Search">MSN</a>.</p>
230 | 
231 | 232 |

The title attribute is optional. Link names may contain letters, 233 | numbers and spaces, but are not case sensitive:

234 | 235 |
I start my morning with a cup of coffee and
236 | [The New York Times][NY Times].
237 | 
238 | [ny times]: http://www.nytimes.com/
239 | 
240 | 241 |

Output:

242 | 243 |
<p>I start my morning with a cup of coffee and
244 | <a href="http://www.nytimes.com/">The New York Times</a>.</p>
245 | 
246 | 247 |

Images

248 | 249 |

Image syntax is very much like link syntax.

250 | 251 |

Inline (titles are optional):

252 | 253 |
![alt text](/path/to/img.jpg "Title")
254 | 
255 | 256 |

Reference-style:

257 | 258 |
![alt text][id]
259 | 
260 | [id]: /path/to/img.jpg "Title"
261 | 
262 | 263 |

Both of the above examples produce the same output:

264 | 265 |
<img src="/path/to/img.jpg" alt="alt text" title="Title" />
266 | 
267 | 268 |

Code

269 | 270 |

In a regular paragraph, you can create code span by wrapping text in 271 | backtick quotes. Any ampersands (&) and angle brackets (< or 272 | >) will automatically be translated into HTML entities. This makes 273 | it easy to use Markdown to write about HTML example code:

274 | 275 |
I strongly recommend against using any `<blink>` tags.
276 | 
277 | I wish SmartyPants used named entities like `&mdash;`
278 | instead of decimal-encoded entites like `&#8212;`.
279 | 
280 | 281 |

Output:

282 | 283 |
<p>I strongly recommend against using any
284 | <code>&lt;blink&gt;</code> tags.</p>
285 | 
286 | <p>I wish SmartyPants used named entities like
287 | <code>&amp;mdash;</code> instead of decimal-encoded
288 | entites like <code>&amp;#8212;</code>.</p>
289 | 
290 | 291 |

To specify an entire block of pre-formatted code, indent every line of 292 | the block by 4 spaces or 1 tab. Just like with code spans, &, <, 293 | and > characters will be escaped automatically.

294 | 295 |

Markdown:

296 | 297 |
If you want your page to validate under XHTML 1.0 Strict,
298 | you've got to put paragraph tags in your blockquotes:
299 | 
300 |     <blockquote>
301 |         <p>For example.</p>
302 |     </blockquote>
303 | 
304 | 305 |

Output:

306 | 307 |
<p>If you want your page to validate under XHTML 1.0 Strict,
308 | you've got to put paragraph tags in your blockquotes:</p>
309 | 
310 | <pre><code>&lt;blockquote&gt;
311 |     &lt;p&gt;For example.&lt;/p&gt;
312 | &lt;/blockquote&gt;
313 | </code></pre>
314 | 
315 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Markdown_Documentation_Basics.text: -------------------------------------------------------------------------------- 1 | Markdown: Basics 2 | ================ 3 | 4 | 11 | 12 | 13 | Getting the Gist of Markdown's Formatting Syntax 14 | ------------------------------------------------ 15 | 16 | This page offers a brief overview of what it's like to use Markdown. 17 | The [syntax page] [s] provides complete, detailed documentation for 18 | every feature, but Markdown should be very easy to pick up simply by 19 | looking at a few examples of it in action. The examples on this page 20 | are written in a before/after style, showing example syntax and the 21 | HTML output produced by Markdown. 22 | 23 | It's also helpful to simply try Markdown out; the [Dingus] [d] is a 24 | web application that allows you type your own Markdown-formatted text 25 | and translate it to XHTML. 26 | 27 | **Note:** This document is itself written using Markdown; you 28 | can [see the source for it by adding '.text' to the URL] [src]. 29 | 30 | [s]: /projects/markdown/syntax "Markdown Syntax" 31 | [d]: /projects/markdown/dingus "Markdown Dingus" 32 | [src]: /projects/markdown/basics.text 33 | 34 | 35 | ## Paragraphs, Headers, Blockquotes ## 36 | 37 | A paragraph is simply one or more consecutive lines of text, separated 38 | by one or more blank lines. (A blank line is any line that looks like a 39 | blank line -- a line containing nothing spaces or tabs is considered 40 | blank.) Normal paragraphs should not be intended with spaces or tabs. 41 | 42 | Markdown offers two styles of headers: *Setext* and *atx*. 43 | Setext-style headers for `

` and `

` are created by 44 | "underlining" with equal signs (`=`) and hyphens (`-`), respectively. 45 | To create an atx-style header, you put 1-6 hash marks (`#`) at the 46 | beginning of the line -- the number of hashes equals the resulting 47 | HTML header level. 48 | 49 | Blockquotes are indicated using email-style '`>`' angle brackets. 50 | 51 | Markdown: 52 | 53 | A First Level Header 54 | ==================== 55 | 56 | A Second Level Header 57 | --------------------- 58 | 59 | Now is the time for all good men to come to 60 | the aid of their country. This is just a 61 | regular paragraph. 62 | 63 | The quick brown fox jumped over the lazy 64 | dog's back. 65 | 66 | ### Header 3 67 | 68 | > This is a blockquote. 69 | > 70 | > This is the second paragraph in the blockquote. 71 | > 72 | > ## This is an H2 in a blockquote 73 | 74 | 75 | Output: 76 | 77 |

A First Level Header

78 | 79 |

A Second Level Header

80 | 81 |

Now is the time for all good men to come to 82 | the aid of their country. This is just a 83 | regular paragraph.

84 | 85 |

The quick brown fox jumped over the lazy 86 | dog's back.

87 | 88 |

Header 3

89 | 90 |
91 |

This is a blockquote.

92 | 93 |

This is the second paragraph in the blockquote.

94 | 95 |

This is an H2 in a blockquote

96 |
97 | 98 | 99 | 100 | ### Phrase Emphasis ### 101 | 102 | Markdown uses asterisks and underscores to indicate spans of emphasis. 103 | 104 | Markdown: 105 | 106 | Some of these words *are emphasized*. 107 | Some of these words _are emphasized also_. 108 | 109 | Use two asterisks for **strong emphasis**. 110 | Or, if you prefer, __use two underscores instead__. 111 | 112 | Output: 113 | 114 |

Some of these words are emphasized. 115 | Some of these words are emphasized also.

116 | 117 |

Use two asterisks for strong emphasis. 118 | Or, if you prefer, use two underscores instead.

119 | 120 | 121 | 122 | ## Lists ## 123 | 124 | Unordered (bulleted) lists use asterisks, pluses, and hyphens (`*`, 125 | `+`, and `-`) as list markers. These three markers are 126 | interchangable; this: 127 | 128 | * Candy. 129 | * Gum. 130 | * Booze. 131 | 132 | this: 133 | 134 | + Candy. 135 | + Gum. 136 | + Booze. 137 | 138 | and this: 139 | 140 | - Candy. 141 | - Gum. 142 | - Booze. 143 | 144 | all produce the same output: 145 | 146 |
    147 |
  • Candy.
  • 148 |
  • Gum.
  • 149 |
  • Booze.
  • 150 |
151 | 152 | Ordered (numbered) lists use regular numbers, followed by periods, as 153 | list markers: 154 | 155 | 1. Red 156 | 2. Green 157 | 3. Blue 158 | 159 | Output: 160 | 161 |
    162 |
  1. Red
  2. 163 |
  3. Green
  4. 164 |
  5. Blue
  6. 165 |
166 | 167 | If you put blank lines between items, you'll get `

` tags for the 168 | list item text. You can create multi-paragraph list items by indenting 169 | the paragraphs by 4 spaces or 1 tab: 170 | 171 | * A list item. 172 | 173 | With multiple paragraphs. 174 | 175 | * Another item in the list. 176 | 177 | Output: 178 | 179 |

    180 |
  • A list item.

    181 |

    With multiple paragraphs.

  • 182 |
  • Another item in the list.

  • 183 |
184 | 185 | 186 | 187 | ### Links ### 188 | 189 | Markdown supports two styles for creating links: *inline* and 190 | *reference*. With both styles, you use square brackets to delimit the 191 | text you want to turn into a link. 192 | 193 | Inline-style links use parentheses immediately after the link text. 194 | For example: 195 | 196 | This is an [example link](http://example.com/). 197 | 198 | Output: 199 | 200 |

This is an 201 | example link.

202 | 203 | Optionally, you may include a title attribute in the parentheses: 204 | 205 | This is an [example link](http://example.com/ "With a Title"). 206 | 207 | Output: 208 | 209 |

This is an 210 | example link.

211 | 212 | Reference-style links allow you to refer to your links by names, which 213 | you define elsewhere in your document: 214 | 215 | I get 10 times more traffic from [Google][1] than from 216 | [Yahoo][2] or [MSN][3]. 217 | 218 | [1]: http://google.com/ "Google" 219 | [2]: http://search.yahoo.com/ "Yahoo Search" 220 | [3]: http://search.msn.com/ "MSN Search" 221 | 222 | Output: 223 | 224 |

I get 10 times more traffic from Google than from Yahoo or MSN.

228 | 229 | The title attribute is optional. Link names may contain letters, 230 | numbers and spaces, but are *not* case sensitive: 231 | 232 | I start my morning with a cup of coffee and 233 | [The New York Times][NY Times]. 234 | 235 | [ny times]: http://www.nytimes.com/ 236 | 237 | Output: 238 | 239 |

I start my morning with a cup of coffee and 240 | The New York Times.

241 | 242 | 243 | ### Images ### 244 | 245 | Image syntax is very much like link syntax. 246 | 247 | Inline (titles are optional): 248 | 249 | ![alt text](/path/to/img.jpg "Title") 250 | 251 | Reference-style: 252 | 253 | ![alt text][id] 254 | 255 | [id]: /path/to/img.jpg "Title" 256 | 257 | Both of the above examples produce the same output: 258 | 259 | alt text 260 | 261 | 262 | 263 | ### Code ### 264 | 265 | In a regular paragraph, you can create code span by wrapping text in 266 | backtick quotes. Any ampersands (`&`) and angle brackets (`<` or 267 | `>`) will automatically be translated into HTML entities. This makes 268 | it easy to use Markdown to write about HTML example code: 269 | 270 | I strongly recommend against using any `` tags. 271 | 272 | I wish SmartyPants used named entities like `—` 273 | instead of decimal-encoded entites like `—`. 274 | 275 | Output: 276 | 277 |

I strongly recommend against using any 278 | <blink> tags.

279 | 280 |

I wish SmartyPants used named entities like 281 | &mdash; instead of decimal-encoded 282 | entites like &#8212;.

283 | 284 | 285 | To specify an entire block of pre-formatted code, indent every line of 286 | the block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`, 287 | and `>` characters will be escaped automatically. 288 | 289 | Markdown: 290 | 291 | If you want your page to validate under XHTML 1.0 Strict, 292 | you've got to put paragraph tags in your blockquotes: 293 | 294 |
295 |

For example.

296 |
297 | 298 | Output: 299 | 300 |

If you want your page to validate under XHTML 1.0 Strict, 301 | you've got to put paragraph tags in your blockquotes:

302 | 303 |
<blockquote>
304 |         <p>For example.</p>
305 |     </blockquote>
306 |     
307 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Markdown_Documentation_Syntax.text: -------------------------------------------------------------------------------- 1 | Markdown: Syntax 2 | ================ 3 | 4 | 11 | 12 | 13 | * [Overview](#overview) 14 | * [Philosophy](#philosophy) 15 | * [Inline HTML](#html) 16 | * [Automatic Escaping for Special Characters](#autoescape) 17 | * [Block Elements](#block) 18 | * [Paragraphs and Line Breaks](#p) 19 | * [Headers](#header) 20 | * [Blockquotes](#blockquote) 21 | * [Lists](#list) 22 | * [Code Blocks](#precode) 23 | * [Horizontal Rules](#hr) 24 | * [Span Elements](#span) 25 | * [Links](#link) 26 | * [Emphasis](#em) 27 | * [Code](#code) 28 | * [Images](#img) 29 | * [Miscellaneous](#misc) 30 | * [Backslash Escapes](#backslash) 31 | * [Automatic Links](#autolink) 32 | 33 | 34 | **Note:** This document is itself written using Markdown; you 35 | can [see the source for it by adding '.text' to the URL][src]. 36 | 37 | [src]: /projects/markdown/syntax.text 38 | 39 | * * * 40 | 41 |

Overview

42 | 43 |

Philosophy

44 | 45 | Markdown is intended to be as easy-to-read and easy-to-write as is feasible. 46 | 47 | Readability, however, is emphasized above all else. A Markdown-formatted 48 | document should be publishable as-is, as plain text, without looking 49 | like it's been marked up with tags or formatting instructions. While 50 | Markdown's syntax has been influenced by several existing text-to-HTML 51 | filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4], 52 | [Grutatext] [5], and [EtText] [6] -- the single biggest source of 53 | inspiration for Markdown's syntax is the format of plain text email. 54 | 55 | [1]: http://docutils.sourceforge.net/mirror/setext.html 56 | [2]: http://www.aaronsw.com/2002/atx/ 57 | [3]: http://textism.com/tools/textile/ 58 | [4]: http://docutils.sourceforge.net/rst.html 59 | [5]: http://www.triptico.com/software/grutatxt.html 60 | [6]: http://ettext.taint.org/doc/ 61 | 62 | To this end, Markdown's syntax is comprised entirely of punctuation 63 | characters, which punctuation characters have been carefully chosen so 64 | as to look like what they mean. E.g., asterisks around a word actually 65 | look like \*emphasis\*. Markdown lists look like, well, lists. Even 66 | blockquotes look like quoted passages of text, assuming you've ever 67 | used email. 68 | 69 | 70 | 71 |

Inline HTML

72 | 73 | Markdown's syntax is intended for one purpose: to be used as a 74 | format for *writing* for the web. 75 | 76 | Markdown is not a replacement for HTML, or even close to it. Its 77 | syntax is very small, corresponding only to a very small subset of 78 | HTML tags. The idea is *not* to create a syntax that makes it easier 79 | to insert HTML tags. In my opinion, HTML tags are already easy to 80 | insert. The idea for Markdown is to make it easy to read, write, and 81 | edit prose. HTML is a *publishing* format; Markdown is a *writing* 82 | format. Thus, Markdown's formatting syntax only addresses issues that 83 | can be conveyed in plain text. 84 | 85 | For any markup that is not covered by Markdown's syntax, you simply 86 | use HTML itself. There's no need to preface it or delimit it to 87 | indicate that you're switching from Markdown to HTML; you just use 88 | the tags. 89 | 90 | The only restrictions are that block-level HTML elements -- e.g. `
`, 91 | ``, `
`, `

`, etc. -- must be separated from surrounding 92 | content by blank lines, and the start and end tags of the block should 93 | not be indented with tabs or spaces. Markdown is smart enough not 94 | to add extra (unwanted) `

` tags around HTML block-level tags. 95 | 96 | For example, to add an HTML table to a Markdown article: 97 | 98 | This is a regular paragraph. 99 | 100 |

101 | 102 | 103 | 104 |
Foo
105 | 106 | This is another regular paragraph. 107 | 108 | Note that Markdown formatting syntax is not processed within block-level 109 | HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an 110 | HTML block. 111 | 112 | Span-level HTML tags -- e.g. ``, ``, or `` -- can be 113 | used anywhere in a Markdown paragraph, list item, or header. If you 114 | want, you can even use HTML tags instead of Markdown formatting; e.g. if 115 | you'd prefer to use HTML `` or `` tags instead of Markdown's 116 | link or image syntax, go right ahead. 117 | 118 | Unlike block-level HTML tags, Markdown syntax *is* processed within 119 | span-level tags. 120 | 121 | 122 |

Automatic Escaping for Special Characters

123 | 124 | In HTML, there are two characters that demand special treatment: `<` 125 | and `&`. Left angle brackets are used to start tags; ampersands are 126 | used to denote HTML entities. If you want to use them as literal 127 | characters, you must escape them as entities, e.g. `<`, and 128 | `&`. 129 | 130 | Ampersands in particular are bedeviling for web writers. If you want to 131 | write about 'AT&T', you need to write '`AT&T`'. You even need to 132 | escape ampersands within URLs. Thus, if you want to link to: 133 | 134 | http://images.google.com/images?num=30&q=larry+bird 135 | 136 | you need to encode the URL as: 137 | 138 | http://images.google.com/images?num=30&q=larry+bird 139 | 140 | in your anchor tag `href` attribute. Needless to say, this is easy to 141 | forget, and is probably the single most common source of HTML validation 142 | errors in otherwise well-marked-up web sites. 143 | 144 | Markdown allows you to use these characters naturally, taking care of 145 | all the necessary escaping for you. If you use an ampersand as part of 146 | an HTML entity, it remains unchanged; otherwise it will be translated 147 | into `&`. 148 | 149 | So, if you want to include a copyright symbol in your article, you can write: 150 | 151 | © 152 | 153 | and Markdown will leave it alone. But if you write: 154 | 155 | AT&T 156 | 157 | Markdown will translate it to: 158 | 159 | AT&T 160 | 161 | Similarly, because Markdown supports [inline HTML](#html), if you use 162 | angle brackets as delimiters for HTML tags, Markdown will treat them as 163 | such. But if you write: 164 | 165 | 4 < 5 166 | 167 | Markdown will translate it to: 168 | 169 | 4 < 5 170 | 171 | However, inside Markdown code spans and blocks, angle brackets and 172 | ampersands are *always* encoded automatically. This makes it easy to use 173 | Markdown to write about HTML code. (As opposed to raw HTML, which is a 174 | terrible format for writing about HTML syntax, because every single `<` 175 | and `&` in your example code needs to be escaped.) 176 | 177 | 178 | * * * 179 | 180 | 181 |

Block Elements

182 | 183 | 184 |

Paragraphs and Line Breaks

185 | 186 | A paragraph is simply one or more consecutive lines of text, separated 187 | by one or more blank lines. (A blank line is any line that looks like a 188 | blank line -- a line containing nothing but spaces or tabs is considered 189 | blank.) Normal paragraphs should not be intended with spaces or tabs. 190 | 191 | The implication of the "one or more consecutive lines of text" rule is 192 | that Markdown supports "hard-wrapped" text paragraphs. This differs 193 | significantly from most other text-to-HTML formatters (including Movable 194 | Type's "Convert Line Breaks" option) which translate every line break 195 | character in a paragraph into a `
` tag. 196 | 197 | When you *do* want to insert a `
` break tag using Markdown, you 198 | end a line with two or more spaces, then type return. 199 | 200 | Yes, this takes a tad more effort to create a `
`, but a simplistic 201 | "every line break is a `
`" rule wouldn't work for Markdown. 202 | Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l] 203 | work best -- and look better -- when you format them with hard breaks. 204 | 205 | [bq]: #blockquote 206 | [l]: #list 207 | 208 | 209 | 210 | 211 | 212 | Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. 213 | 214 | Setext-style headers are "underlined" using equal signs (for first-level 215 | headers) and dashes (for second-level headers). For example: 216 | 217 | This is an H1 218 | ============= 219 | 220 | This is an H2 221 | ------------- 222 | 223 | Any number of underlining `=`'s or `-`'s will work. 224 | 225 | Atx-style headers use 1-6 hash characters at the start of the line, 226 | corresponding to header levels 1-6. For example: 227 | 228 | # This is an H1 229 | 230 | ## This is an H2 231 | 232 | ###### This is an H6 233 | 234 | Optionally, you may "close" atx-style headers. This is purely 235 | cosmetic -- you can use this if you think it looks better. The 236 | closing hashes don't even need to match the number of hashes 237 | used to open the header. (The number of opening hashes 238 | determines the header level.) : 239 | 240 | # This is an H1 # 241 | 242 | ## This is an H2 ## 243 | 244 | ### This is an H3 ###### 245 | 246 | 247 |

Blockquotes

248 | 249 | Markdown uses email-style `>` characters for blockquoting. If you're 250 | familiar with quoting passages of text in an email message, then you 251 | know how to create a blockquote in Markdown. It looks best if you hard 252 | wrap the text and put a `>` before every line: 253 | 254 | > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, 255 | > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. 256 | > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. 257 | > 258 | > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse 259 | > id sem consectetuer libero luctus adipiscing. 260 | 261 | Markdown allows you to be lazy and only put the `>` before the first 262 | line of a hard-wrapped paragraph: 263 | 264 | > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, 265 | consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. 266 | Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. 267 | 268 | > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse 269 | id sem consectetuer libero luctus adipiscing. 270 | 271 | Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by 272 | adding additional levels of `>`: 273 | 274 | > This is the first level of quoting. 275 | > 276 | > > This is nested blockquote. 277 | > 278 | > Back to the first level. 279 | 280 | Blockquotes can contain other Markdown elements, including headers, lists, 281 | and code blocks: 282 | 283 | > ## This is a header. 284 | > 285 | > 1. This is the first list item. 286 | > 2. This is the second list item. 287 | > 288 | > Here's some example code: 289 | > 290 | > return shell_exec("echo $input | $markdown_script"); 291 | 292 | Any decent text editor should make email-style quoting easy. For 293 | example, with BBEdit, you can make a selection and choose Increase 294 | Quote Level from the Text menu. 295 | 296 | 297 |

Lists

298 | 299 | Markdown supports ordered (numbered) and unordered (bulleted) lists. 300 | 301 | Unordered lists use asterisks, pluses, and hyphens -- interchangably 302 | -- as list markers: 303 | 304 | * Red 305 | * Green 306 | * Blue 307 | 308 | is equivalent to: 309 | 310 | + Red 311 | + Green 312 | + Blue 313 | 314 | and: 315 | 316 | - Red 317 | - Green 318 | - Blue 319 | 320 | Ordered lists use numbers followed by periods: 321 | 322 | 1. Bird 323 | 2. McHale 324 | 3. Parish 325 | 326 | It's important to note that the actual numbers you use to mark the 327 | list have no effect on the HTML output Markdown produces. The HTML 328 | Markdown produces from the above list is: 329 | 330 |
    331 |
  1. Bird
  2. 332 |
  3. McHale
  4. 333 |
  5. Parish
  6. 334 |
335 | 336 | If you instead wrote the list in Markdown like this: 337 | 338 | 1. Bird 339 | 1. McHale 340 | 1. Parish 341 | 342 | or even: 343 | 344 | 3. Bird 345 | 1. McHale 346 | 8. Parish 347 | 348 | you'd get the exact same HTML output. The point is, if you want to, 349 | you can use ordinal numbers in your ordered Markdown lists, so that 350 | the numbers in your source match the numbers in your published HTML. 351 | But if you want to be lazy, you don't have to. 352 | 353 | If you do use lazy list numbering, however, you should still start the 354 | list with the number 1. At some point in the future, Markdown may support 355 | starting ordered lists at an arbitrary number. 356 | 357 | List markers typically start at the left margin, but may be indented by 358 | up to three spaces. List markers must be followed by one or more spaces 359 | or a tab. 360 | 361 | To make lists look nice, you can wrap items with hanging indents: 362 | 363 | * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 364 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, 365 | viverra nec, fringilla in, laoreet vitae, risus. 366 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. 367 | Suspendisse id sem consectetuer libero luctus adipiscing. 368 | 369 | But if you want to be lazy, you don't have to: 370 | 371 | * Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 372 | Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, 373 | viverra nec, fringilla in, laoreet vitae, risus. 374 | * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. 375 | Suspendisse id sem consectetuer libero luctus adipiscing. 376 | 377 | If list items are separated by blank lines, Markdown will wrap the 378 | items in `

` tags in the HTML output. For example, this input: 379 | 380 | * Bird 381 | * Magic 382 | 383 | will turn into: 384 | 385 |

    386 |
  • Bird
  • 387 |
  • Magic
  • 388 |
389 | 390 | But this: 391 | 392 | * Bird 393 | 394 | * Magic 395 | 396 | will turn into: 397 | 398 |
    399 |
  • Bird

  • 400 |
  • Magic

  • 401 |
402 | 403 | List items may consist of multiple paragraphs. Each subsequent 404 | paragraph in a list item must be intended by either 4 spaces 405 | or one tab: 406 | 407 | 1. This is a list item with two paragraphs. Lorem ipsum dolor 408 | sit amet, consectetuer adipiscing elit. Aliquam hendrerit 409 | mi posuere lectus. 410 | 411 | Vestibulum enim wisi, viverra nec, fringilla in, laoreet 412 | vitae, risus. Donec sit amet nisl. Aliquam semper ipsum 413 | sit amet velit. 414 | 415 | 2. Suspendisse id sem consectetuer libero luctus adipiscing. 416 | 417 | It looks nice if you indent every line of the subsequent 418 | paragraphs, but here again, Markdown will allow you to be 419 | lazy: 420 | 421 | * This is a list item with two paragraphs. 422 | 423 | This is the second paragraph in the list item. You're 424 | only required to indent the first line. Lorem ipsum dolor 425 | sit amet, consectetuer adipiscing elit. 426 | 427 | * Another item in the same list. 428 | 429 | To put a blockquote within a list item, the blockquote's `>` 430 | delimiters need to be indented: 431 | 432 | * A list item with a blockquote: 433 | 434 | > This is a blockquote 435 | > inside a list item. 436 | 437 | To put a code block within a list item, the code block needs 438 | to be indented *twice* -- 8 spaces or two tabs: 439 | 440 | * A list item with a code block: 441 | 442 | 443 | 444 | 445 | It's worth noting that it's possible to trigger an ordered list by 446 | accident, by writing something like this: 447 | 448 | 1986. What a great season. 449 | 450 | In other words, a *number-period-space* sequence at the beginning of a 451 | line. To avoid this, you can backslash-escape the period: 452 | 453 | 1986\. What a great season. 454 | 455 | 456 | 457 |

Code Blocks

458 | 459 | Pre-formatted code blocks are used for writing about programming or 460 | markup source code. Rather than forming normal paragraphs, the lines 461 | of a code block are interpreted literally. Markdown wraps a code block 462 | in both `
` and `` tags.
463 | 
464 | To produce a code block in Markdown, simply indent every line of the
465 | block by at least 4 spaces or 1 tab. For example, given this input:
466 | 
467 |     This is a normal paragraph:
468 | 
469 |         This is a code block.
470 | 
471 | Markdown will generate:
472 | 
473 |     

This is a normal paragraph:

474 | 475 |
This is a code block.
476 |     
477 | 478 | One level of indentation -- 4 spaces or 1 tab -- is removed from each 479 | line of the code block. For example, this: 480 | 481 | Here is an example of AppleScript: 482 | 483 | tell application "Foo" 484 | beep 485 | end tell 486 | 487 | will turn into: 488 | 489 |

Here is an example of AppleScript:

490 | 491 |
tell application "Foo"
492 |         beep
493 |     end tell
494 |     
495 | 496 | A code block continues until it reaches a line that is not indented 497 | (or the end of the article). 498 | 499 | Within a code block, ampersands (`&`) and angle brackets (`<` and `>`) 500 | are automatically converted into HTML entities. This makes it very 501 | easy to include example HTML source code using Markdown -- just paste 502 | it and indent it, and Markdown will handle the hassle of encoding the 503 | ampersands and angle brackets. For example, this: 504 | 505 | 508 | 509 | will turn into: 510 | 511 |
<div class="footer">
512 |         &copy; 2004 Foo Corporation
513 |     </div>
514 |     
515 | 516 | Regular Markdown syntax is not processed within code blocks. E.g., 517 | asterisks are just literal asterisks within a code block. This means 518 | it's also easy to use Markdown to write about Markdown's own syntax. 519 | 520 | 521 | 522 |

Horizontal Rules

523 | 524 | You can produce a horizontal rule tag (`
`) by placing three or 525 | more hyphens, asterisks, or underscores on a line by themselves. If you 526 | wish, you may use spaces between the hyphens or asterisks. Each of the 527 | following lines will produce a horizontal rule: 528 | 529 | * * * 530 | 531 | *** 532 | 533 | ***** 534 | 535 | - - - 536 | 537 | --------------------------------------- 538 | 539 | _ _ _ 540 | 541 | 542 | * * * 543 | 544 |

Span Elements

545 | 546 | 547 | 548 | Markdown supports two style of links: *inline* and *reference*. 549 | 550 | In both styles, the link text is delimited by [square brackets]. 551 | 552 | To create an inline link, use a set of regular parentheses immediately 553 | after the link text's closing square bracket. Inside the parentheses, 554 | put the URL where you want the link to point, along with an *optional* 555 | title for the link, surrounded in quotes. For example: 556 | 557 | This is [an example](http://example.com/ "Title") inline link. 558 | 559 | [This link](http://example.net/) has no title attribute. 560 | 561 | Will produce: 562 | 563 |

This is 564 | an example inline link.

565 | 566 |

This link has no 567 | title attribute.

568 | 569 | If you're referring to a local resource on the same server, you can 570 | use relative paths: 571 | 572 | See my [About](/about/) page for details. 573 | 574 | Reference-style links use a second set of square brackets, inside 575 | which you place a label of your choosing to identify the link: 576 | 577 | This is [an example][id] reference-style link. 578 | 579 | You can optionally use a space to separate the sets of brackets: 580 | 581 | This is [an example] [id] reference-style link. 582 | 583 | Then, anywhere in the document, you define your link label like this, 584 | on a line by itself: 585 | 586 | [id]: http://example.com/ "Optional Title Here" 587 | 588 | That is: 589 | 590 | * Square brackets containing the link identifier (optionally 591 | indented from the left margin using up to three spaces); 592 | * followed by a colon; 593 | * followed by one or more spaces (or tabs); 594 | * followed by the URL for the link; 595 | * optionally followed by a title attribute for the link, enclosed 596 | in double or single quotes. 597 | 598 | The link URL may, optionally, be surrounded by angle brackets: 599 | 600 | [id]: "Optional Title Here" 601 | 602 | You can put the title attribute on the next line and use extra spaces 603 | or tabs for padding, which tends to look better with longer URLs: 604 | 605 | [id]: http://example.com/longish/path/to/resource/here 606 | "Optional Title Here" 607 | 608 | Link definitions are only used for creating links during Markdown 609 | processing, and are stripped from your document in the HTML output. 610 | 611 | Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links: 612 | 613 | [link text][a] 614 | [link text][A] 615 | 616 | are equivalent. 617 | 618 | The *implicit link name* shortcut allows you to omit the name of the 619 | link, in which case the link text itself is used as the name. 620 | Just use an empty set of square brackets -- e.g., to link the word 621 | "Google" to the google.com web site, you could simply write: 622 | 623 | [Google][] 624 | 625 | And then define the link: 626 | 627 | [Google]: http://google.com/ 628 | 629 | Because link names may contain spaces, this shortcut even works for 630 | multiple words in the link text: 631 | 632 | Visit [Daring Fireball][] for more information. 633 | 634 | And then define the link: 635 | 636 | [Daring Fireball]: http://daringfireball.net/ 637 | 638 | Link definitions can be placed anywhere in your Markdown document. I 639 | tend to put them immediately after each paragraph in which they're 640 | used, but if you want, you can put them all at the end of your 641 | document, sort of like footnotes. 642 | 643 | Here's an example of reference links in action: 644 | 645 | I get 10 times more traffic from [Google] [1] than from 646 | [Yahoo] [2] or [MSN] [3]. 647 | 648 | [1]: http://google.com/ "Google" 649 | [2]: http://search.yahoo.com/ "Yahoo Search" 650 | [3]: http://search.msn.com/ "MSN Search" 651 | 652 | Using the implicit link name shortcut, you could instead write: 653 | 654 | I get 10 times more traffic from [Google][] than from 655 | [Yahoo][] or [MSN][]. 656 | 657 | [google]: http://google.com/ "Google" 658 | [yahoo]: http://search.yahoo.com/ "Yahoo Search" 659 | [msn]: http://search.msn.com/ "MSN Search" 660 | 661 | Both of the above examples will produce the following HTML output: 662 | 663 |

I get 10 times more traffic from Google than from 665 | Yahoo 666 | or MSN.

667 | 668 | For comparison, here is the same paragraph written using 669 | Markdown's inline link style: 670 | 671 | I get 10 times more traffic from [Google](http://google.com/ "Google") 672 | than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or 673 | [MSN](http://search.msn.com/ "MSN Search"). 674 | 675 | The point of reference-style links is not that they're easier to 676 | write. The point is that with reference-style links, your document 677 | source is vastly more readable. Compare the above examples: using 678 | reference-style links, the paragraph itself is only 81 characters 679 | long; with inline-style links, it's 176 characters; and as raw HTML, 680 | it's 234 characters. In the raw HTML, there's more markup than there 681 | is text. 682 | 683 | With Markdown's reference-style links, a source document much more 684 | closely resembles the final output, as rendered in a browser. By 685 | allowing you to move the markup-related metadata out of the paragraph, 686 | you can add links without interrupting the narrative flow of your 687 | prose. 688 | 689 | 690 |

Emphasis

691 | 692 | Markdown treats asterisks (`*`) and underscores (`_`) as indicators of 693 | emphasis. Text wrapped with one `*` or `_` will be wrapped with an 694 | HTML `` tag; double `*`'s or `_`'s will be wrapped with an HTML 695 | `` tag. E.g., this input: 696 | 697 | *single asterisks* 698 | 699 | _single underscores_ 700 | 701 | **double asterisks** 702 | 703 | __double underscores__ 704 | 705 | will produce: 706 | 707 | single asterisks 708 | 709 | single underscores 710 | 711 | double asterisks 712 | 713 | double underscores 714 | 715 | You can use whichever style you prefer; the lone restriction is that 716 | the same character must be used to open and close an emphasis span. 717 | 718 | Emphasis can be used in the middle of a word: 719 | 720 | un*fucking*believable 721 | 722 | But if you surround an `*` or `_` with spaces, it'll be treated as a 723 | literal asterisk or underscore. 724 | 725 | To produce a literal asterisk or underscore at a position where it 726 | would otherwise be used as an emphasis delimiter, you can backslash 727 | escape it: 728 | 729 | \*this text is surrounded by literal asterisks\* 730 | 731 | 732 | 733 |

Code

734 | 735 | To indicate a span of code, wrap it with backtick quotes (`` ` ``). 736 | Unlike a pre-formatted code block, a code span indicates code within a 737 | normal paragraph. For example: 738 | 739 | Use the `printf()` function. 740 | 741 | will produce: 742 | 743 |

Use the printf() function.

744 | 745 | To include a literal backtick character within a code span, you can use 746 | multiple backticks as the opening and closing delimiters: 747 | 748 | ``There is a literal backtick (`) here.`` 749 | 750 | which will produce this: 751 | 752 |

There is a literal backtick (`) here.

753 | 754 | The backtick delimiters surrounding a code span may include spaces -- 755 | one after the opening, one before the closing. This allows you to place 756 | literal backtick characters at the beginning or end of a code span: 757 | 758 | A single backtick in a code span: `` ` `` 759 | 760 | A backtick-delimited string in a code span: `` `foo` `` 761 | 762 | will produce: 763 | 764 |

A single backtick in a code span: `

765 | 766 |

A backtick-delimited string in a code span: `foo`

767 | 768 | With a code span, ampersands and angle brackets are encoded as HTML 769 | entities automatically, which makes it easy to include example HTML 770 | tags. Markdown will turn this: 771 | 772 | Please don't use any `` tags. 773 | 774 | into: 775 | 776 |

Please don't use any <blink> tags.

777 | 778 | You can write this: 779 | 780 | `—` is the decimal-encoded equivalent of `—`. 781 | 782 | to produce: 783 | 784 |

&#8212; is the decimal-encoded 785 | equivalent of &mdash;.

786 | 787 | 788 | 789 |

Images

790 | 791 | Admittedly, it's fairly difficult to devise a "natural" syntax for 792 | placing images into a plain text document format. 793 | 794 | Markdown uses an image syntax that is intended to resemble the syntax 795 | for links, allowing for two styles: *inline* and *reference*. 796 | 797 | Inline image syntax looks like this: 798 | 799 | ![Alt text](/path/to/img.jpg) 800 | 801 | ![Alt text](/path/to/img.jpg "Optional title") 802 | 803 | That is: 804 | 805 | * An exclamation mark: `!`; 806 | * followed by a set of square brackets, containing the `alt` 807 | attribute text for the image; 808 | * followed by a set of parentheses, containing the URL or path to 809 | the image, and an optional `title` attribute enclosed in double 810 | or single quotes. 811 | 812 | Reference-style image syntax looks like this: 813 | 814 | ![Alt text][id] 815 | 816 | Where "id" is the name of a defined image reference. Image references 817 | are defined using syntax identical to link references: 818 | 819 | [id]: url/to/image "Optional title attribute" 820 | 821 | As of this writing, Markdown has no syntax for specifying the 822 | dimensions of an image; if this is important to you, you can simply 823 | use regular HTML `` tags. 824 | 825 | 826 | * * * 827 | 828 | 829 |

Miscellaneous

830 | 831 | 832 | 833 | Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this: 834 | 835 | 836 | 837 | Markdown will turn this into: 838 | 839 | http://example.com/ 840 | 841 | Automatic links for email addresses work similarly, except that 842 | Markdown will also perform a bit of randomized decimal and hex 843 | entity-encoding to help obscure your address from address-harvesting 844 | spambots. For example, Markdown will turn this: 845 | 846 | 847 | 848 | into something like this: 849 | 850 | address@exa 853 | mple.com 854 | 855 | which will render in a browser as a clickable link to "address@example.com". 856 | 857 | (This sort of entity-encoding trick will indeed fool many, if not 858 | most, address-harvesting bots, but it definitely won't fool all of 859 | them. It's better than nothing, but an address published in this way 860 | will probably eventually start receiving spam.) 861 | 862 | 863 | 864 |

Backslash Escapes

865 | 866 | Markdown allows you to use backslash escapes to generate literal 867 | characters which would otherwise have special meaning in Markdown's 868 | formatting syntax. For example, if you wanted to surround a word with 869 | literal asterisks (instead of an HTML `` tag), you can backslashes 870 | before the asterisks, like this: 871 | 872 | \*literal asterisks\* 873 | 874 | Markdown provides backslash escapes for the following characters: 875 | 876 | \ backslash 877 | ` backtick 878 | * asterisk 879 | _ underscore 880 | {} curly braces 881 | [] square brackets 882 | () parentheses 883 | # hash mark 884 | + plus sign 885 | - minus sign (hyphen) 886 | . dot 887 | ! exclamation mark 888 | 889 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Nested_blockquotes.html: -------------------------------------------------------------------------------- 1 |
2 |

foo

3 | 4 |
5 |

bar

6 |
7 | 8 |

foo

9 |
10 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Nested_blockquotes.text: -------------------------------------------------------------------------------- 1 | > foo 2 | > 3 | > > bar 4 | > 5 | > foo 6 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Ordered_and_unordered_lists.html: -------------------------------------------------------------------------------- 1 |

Unordered

2 | 3 |

Asterisks tight:

4 | 5 |
    6 |
  • asterisk 1
  • 7 |
  • asterisk 2
  • 8 |
  • asterisk 3
  • 9 |
10 | 11 |

Asterisks loose:

12 | 13 |
    14 |
  • asterisk 1

  • 15 |
  • asterisk 2

  • 16 |
  • asterisk 3

  • 17 |
18 | 19 |
20 | 21 |

Pluses tight:

22 | 23 |
    24 |
  • Plus 1
  • 25 |
  • Plus 2
  • 26 |
  • Plus 3
  • 27 |
28 | 29 |

Pluses loose:

30 | 31 |
    32 |
  • Plus 1

  • 33 |
  • Plus 2

  • 34 |
  • Plus 3

  • 35 |
36 | 37 |
38 | 39 |

Minuses tight:

40 | 41 |
    42 |
  • Minus 1
  • 43 |
  • Minus 2
  • 44 |
  • Minus 3
  • 45 |
46 | 47 |

Minuses loose:

48 | 49 |
    50 |
  • Minus 1

  • 51 |
  • Minus 2

  • 52 |
  • Minus 3

  • 53 |
54 | 55 |

Ordered

56 | 57 |

Tight:

58 | 59 |
    60 |
  1. First
  2. 61 |
  3. Second
  4. 62 |
  5. Third
  6. 63 |
64 | 65 |

and:

66 | 67 |
    68 |
  1. One
  2. 69 |
  3. Two
  4. 70 |
  5. Three
  6. 71 |
72 | 73 |

Loose using tabs:

74 | 75 |
    76 |
  1. First

  2. 77 |
  3. Second

  4. 78 |
  5. Third

  6. 79 |
80 | 81 |

and using spaces:

82 | 83 |
    84 |
  1. One

  2. 85 |
  3. Two

  4. 86 |
  5. Three

  6. 87 |
88 | 89 |

Multiple paragraphs:

90 | 91 |
    92 |
  1. Item 1, graf one.

    93 | 94 |

    Item 2. graf two. The quick brown fox jumped over the lazy dog's 95 | back.

  2. 96 |
  3. Item 2.

  4. 97 |
  5. Item 3.

  6. 98 |
99 | 100 |

Nested

101 | 102 |
    103 |
  • Tab 104 |
      105 |
    • Tab 106 |
        107 |
      • Tab
      • 108 |
    • 109 |
  • 110 |
111 | 112 |

Here's another:

113 | 114 |
    115 |
  1. First
  2. 116 |
  3. Second: 117 |
      118 |
    • Fee
    • 119 |
    • Fie
    • 120 |
    • Foe
    • 121 |
  4. 122 |
  5. Third
  6. 123 |
124 | 125 |

Same thing but with paragraphs:

126 | 127 |
    128 |
  1. First

  2. 129 |
  3. Second:

    130 | 131 |
      132 |
    • Fee
    • 133 |
    • Fie
    • 134 |
    • Foe
    • 135 |
  4. 136 |
  5. Third

  6. 137 |
138 | 139 | 140 |

This was an error in Markdown 1.0.1:

141 | 142 |
    143 |
  • this

    144 | 145 |
    • sub
    146 | 147 |

    that

  • 148 |
149 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Ordered_and_unordered_lists.text: -------------------------------------------------------------------------------- 1 | ## Unordered 2 | 3 | Asterisks tight: 4 | 5 | * asterisk 1 6 | * asterisk 2 7 | * asterisk 3 8 | 9 | 10 | Asterisks loose: 11 | 12 | * asterisk 1 13 | 14 | * asterisk 2 15 | 16 | * asterisk 3 17 | 18 | * * * 19 | 20 | Pluses tight: 21 | 22 | + Plus 1 23 | + Plus 2 24 | + Plus 3 25 | 26 | 27 | Pluses loose: 28 | 29 | + Plus 1 30 | 31 | + Plus 2 32 | 33 | + Plus 3 34 | 35 | * * * 36 | 37 | 38 | Minuses tight: 39 | 40 | - Minus 1 41 | - Minus 2 42 | - Minus 3 43 | 44 | 45 | Minuses loose: 46 | 47 | - Minus 1 48 | 49 | - Minus 2 50 | 51 | - Minus 3 52 | 53 | 54 | ## Ordered 55 | 56 | Tight: 57 | 58 | 1. First 59 | 2. Second 60 | 3. Third 61 | 62 | and: 63 | 64 | 1. One 65 | 2. Two 66 | 3. Three 67 | 68 | 69 | Loose using tabs: 70 | 71 | 1. First 72 | 73 | 2. Second 74 | 75 | 3. Third 76 | 77 | and using spaces: 78 | 79 | 1. One 80 | 81 | 2. Two 82 | 83 | 3. Three 84 | 85 | Multiple paragraphs: 86 | 87 | 1. Item 1, graf one. 88 | 89 | Item 2. graf two. The quick brown fox jumped over the lazy dog's 90 | back. 91 | 92 | 2. Item 2. 93 | 94 | 3. Item 3. 95 | 96 | 97 | 98 | ## Nested 99 | 100 | * Tab 101 | * Tab 102 | * Tab 103 | 104 | Here's another: 105 | 106 | 1. First 107 | 2. Second: 108 | * Fee 109 | * Fie 110 | * Foe 111 | 3. Third 112 | 113 | Same thing but with paragraphs: 114 | 115 | 1. First 116 | 117 | 2. Second: 118 | * Fee 119 | * Fie 120 | * Foe 121 | 122 | 3. Third 123 | 124 | 125 | This was an error in Markdown 1.0.1: 126 | 127 | * this 128 | 129 | * sub 130 | 131 | that 132 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Strong_and_em_together.html: -------------------------------------------------------------------------------- 1 |

This is strong and em.

2 | 3 |

So is this word.

4 | 5 |

This is strong and em.

6 | 7 |

So is this word.

8 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Strong_and_em_together.text: -------------------------------------------------------------------------------- 1 | ***This is strong and em.*** 2 | 3 | So is ***this*** word. 4 | 5 | ___This is strong and em.___ 6 | 7 | So is ___this___ word. 8 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Tabs.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • this is a list item 3 | indented with tabs

  • 4 |
  • this is a list item 5 | indented with spaces

  • 6 |
7 | 8 |

Code:

9 | 10 |
this code block is indented by one tab
11 | 
12 | 13 |

And:

14 | 15 |
    this code block is indented by two tabs
16 | 
17 | 18 |

And:

19 | 20 |
+   this is an example list item
21 |     indented with tabs
22 | 
23 | +   this is an example list item
24 |     indented with spaces
25 | 
26 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Tabs.text: -------------------------------------------------------------------------------- 1 | + this is a list item 2 | indented with tabs 3 | 4 | + this is a list item 5 | indented with spaces 6 | 7 | Code: 8 | 9 | this code block is indented by one tab 10 | 11 | And: 12 | 13 | this code block is indented by two tabs 14 | 15 | And: 16 | 17 | + this is an example list item 18 | indented with tabs 19 | 20 | + this is an example list item 21 | indented with spaces 22 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Tidyness.html: -------------------------------------------------------------------------------- 1 |
2 |

A list within a blockquote:

3 |
    4 |
  • asterisk 1
  • 5 |
  • asterisk 2
  • 6 |
  • asterisk 3
  • 7 |
8 |
9 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mdtest-1.1/Tidyness.text: -------------------------------------------------------------------------------- 1 | > A list within a blockquote: 2 | > 3 | > * asterisk 1 4 | > * asterisk 2 5 | > * asterisk 3 6 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/!readme.txt: -------------------------------------------------------------------------------- 1 |  2 | iterates through all the test files in a given folder and generates file-based output 3 | this is essentially the same as running the unit tests, but with diff-able results 4 | 5 | two files should be present for each test: 6 | 7 | test_name.text -- input (raw markdown) 8 | test_name.html -- output (expected cooked html output from reference markdown engine) 9 | 10 | this file will be generated if, and ONLY IF, the expected output does not match the actual output: 11 | 12 | test_name.xxxx.actual.html -- actual output (actual cooked html output from our markdown c# engine) 13 | -- xxxx is the 16-bit CRC checksum of the file contents; this is included 14 | so you can tell if the contents of a failing test have changed 15 | 16 | Contents 17 | ======== 18 | 19 | beginnings of MarkdownSharp test suite -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/code-inside-list.html: -------------------------------------------------------------------------------- 1 |
    2 |
  1. one

    3 | 4 |
    code<t>
     5 | indented 8 spaces<t>
     6 | 
  2. 7 |
  3. two

    8 | 9 |
    code<t>
    10 |     idented-12-spaces<t>
    11 | 
  4. 12 |
  5. three

    13 | 14 |
    code<t>
    15 | 
    16 |     indented-12-spaces<t>
    17 | 
  6. 18 |
-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/code-inside-list.text: -------------------------------------------------------------------------------- 1 | 1. one 2 | 3 | code 4 | indented 8 spaces 5 | 6 | 2. two 7 | 8 | code 9 | idented-12-spaces 10 | 11 | 3. three 12 | 13 | code 14 | 15 | indented-12-spaces -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-cr.html: -------------------------------------------------------------------------------- 1 |

Header

2 | 3 |
4 | 5 |

Some bold Some italic and a link

6 | 7 |

A little code sample

8 | 9 |
</head>
10 | <title>Web Page Title</title>
11 | </head>
12 | 
13 | 14 |

A picture

15 | 16 |

alt text

17 | 18 |

A list

19 | 20 |
    21 |
  • apples
  • 22 |
  • oranges
  • 23 |
  • eggs
  • 24 |
25 | 26 |

A numbered list

27 | 28 |
    29 |
  1. a
  2. 30 |
  3. b
  4. 31 |
  5. c
  6. 32 |
33 | 34 |

A little quote

35 | 36 |
37 |

It is now time for all good men to come to the aid of their country.

38 |
39 | 40 |

A final paragraph.

41 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-cr.text: -------------------------------------------------------------------------------- 1 | ##Header## ---------- Some **bold** Some *italic* and [a link][1] A little code sample Web Page Title A picture ![alt text][2] A list - apples - oranges - eggs A numbered list 1. a 2. b 3. c A little quote > It is now time for all good men to come to the aid of their country. A final paragraph. [1]: http://www.google.com [2]: http://www.google.com/intl/en_ALL/images/logo.gif -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-crlf.html: -------------------------------------------------------------------------------- 1 |

Header

2 | 3 |
4 | 5 |

Some bold Some italic and a link

6 | 7 |

A little code sample

8 | 9 |
</head>
10 | <title>Web Page Title</title>
11 | </head>
12 | 
13 | 14 |

A picture

15 | 16 |

alt text

17 | 18 |

A list

19 | 20 |
    21 |
  • apples
  • 22 |
  • oranges
  • 23 |
  • eggs
  • 24 |
25 | 26 |

A numbered list

27 | 28 |
    29 |
  1. a
  2. 30 |
  3. b
  4. 31 |
  5. c
  6. 32 |
33 | 34 |

A little quote

35 | 36 |
37 |

It is now time for all good men to come to the aid of their country.

38 |
39 | 40 |

A final paragraph.

41 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-crlf.text: -------------------------------------------------------------------------------- 1 | ##Header## 2 | 3 | ---------- 4 | 5 | Some **bold** Some *italic* and [a link][1] 6 | 7 | A little code sample 8 | 9 | 10 | Web Page Title 11 | 12 | 13 | A picture 14 | 15 | ![alt text][2] 16 | 17 | A list 18 | 19 | - apples 20 | - oranges 21 | - eggs 22 | 23 | A numbered list 24 | 25 | 1. a 26 | 2. b 27 | 3. c 28 | 29 | A little quote 30 | 31 | > It is now time for all good men to come to the aid of their country. 32 | 33 | A final paragraph. 34 | 35 | [1]: http://www.google.com 36 | [2]: http://www.google.com/intl/en_ALL/images/logo.gif -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-lf.html: -------------------------------------------------------------------------------- 1 |

Header

2 | 3 |
4 | 5 |

Some bold Some italic and a link

6 | 7 |

A little code sample

8 | 9 |
</head>
10 | <title>Web Page Title</title>
11 | </head>
12 | 
13 | 14 |

A picture

15 | 16 |

alt text

17 | 18 |

A list

19 | 20 |
    21 |
  • apples
  • 22 |
  • oranges
  • 23 |
  • eggs
  • 24 |
25 | 26 |

A numbered list

27 | 28 |
    29 |
  1. a
  2. 30 |
  3. b
  4. 31 |
  5. c
  6. 32 |
33 | 34 |

A little quote

35 | 36 |
37 |

It is now time for all good men to come to the aid of their country.

38 |
39 | 40 |

A final paragraph.

41 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/line-endings-lf.text: -------------------------------------------------------------------------------- 1 | ##Header## 2 | 3 | ---------- 4 | 5 | Some **bold** Some *italic* and [a link][1] 6 | 7 | A little code sample 8 | 9 | 10 | Web Page Title 11 | 12 | 13 | A picture 14 | 15 | ![alt text][2] 16 | 17 | A list 18 | 19 | - apples 20 | - oranges 21 | - eggs 22 | 23 | A numbered list 24 | 25 | 1. a 26 | 2. b 27 | 3. c 28 | 29 | A little quote 30 | 31 | > It is now time for all good men to come to the aid of their country. 32 | 33 | A final paragraph. 34 | 35 | [1]: http://www.google.com 36 | [2]: http://www.google.com/intl/en_ALL/images/logo.gif -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/markdown-readme.html: -------------------------------------------------------------------------------- 1 |

Markdown

2 | 3 |

Version 1.0.1 - Tue 14 Dec 2004

4 | 5 |

by John Gruber
6 | http://daringfireball.net/

7 | 8 |

Introduction

9 | 10 |

Markdown is a text-to-HTML conversion tool for web writers. Markdown 11 | allows you to write using an easy-to-read, easy-to-write plain text 12 | format, then convert it to structurally valid XHTML (or HTML).

13 | 14 |

Thus, "Markdown" is two things: a plain text markup syntax, and a 15 | software tool, written in Perl, that converts the plain text markup 16 | to HTML.

17 | 18 |

Markdown works both as a Movable Type plug-in and as a standalone Perl 19 | script -- which means it can also be used as a text filter in BBEdit 20 | (or any other application that supporst filters written in Perl).

21 | 22 |

Full documentation of Markdown's syntax and configuration options is 23 | available on the web: http://daringfireball.net/projects/markdown/. 24 | (Note: this readme file is formatted in Markdown.)

25 | 26 |

Installation and Requirements

27 | 28 |

Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century. 29 | Markdown also requires the standard Perl library module Digest::MD5.

30 | 31 |

Movable Type

32 | 33 |

Markdown works with Movable Type version 2.6 or later (including 34 | MT 3.0 or later).

35 | 36 |
    37 |
  1. Copy the "Markdown.pl" file into your Movable Type "plugins" 38 | directory. The "plugins" directory should be in the same directory 39 | as "mt.cgi"; if the "plugins" directory doesn't already exist, use 40 | your FTP program to create it. Your installation should look like 41 | this:

    42 | 43 |
    (mt home)/plugins/Markdown.pl
     44 | 
  2. 45 |
  3. Once installed, Markdown will appear as an option in Movable Type's 46 | Text Formatting pop-up menu. This is selectable on a per-post basis. 47 | Markdown translates your posts to HTML when you publish; the posts 48 | themselves are stored in your MT database in Markdown format.

  4. 49 |
  5. If you also install SmartyPants 1.5 (or later), Markdown will offer 50 | a second text formatting option: "Markdown with SmartyPants". This 51 | option is the same as the regular "Markdown" formatter, except that 52 | automatically uses SmartyPants to create typographically correct 53 | curly quotes, em-dashes, and ellipses. See the SmartyPants web page 54 | for more information: http://daringfireball.net/projects/smartypants/

  6. 55 |
  7. To make Markdown (or "Markdown with SmartyPants") your default 56 | text formatting option for new posts, go to Weblog Config -> 57 | Preferences.

  8. 58 |
59 | 60 |

Note that by default, Markdown produces XHTML output. To configure 61 | Markdown to produce HTML 4 output, see "Configuration", below.

62 | 63 |

Blosxom

64 | 65 |

Markdown works with Blosxom version 2.x.

66 | 67 |
    68 |
  1. Rename the "Markdown.pl" plug-in to "Markdown" (case is 69 | important). Movable Type requires plug-ins to have a ".pl" 70 | extension; Blosxom forbids it.

  2. 71 |
  3. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder. 72 | If you're not sure where your Blosxom plug-ins folder is, see the 73 | Blosxom documentation for information.

  4. 74 |
  5. That's it. The entries in your weblog will now automatically be 75 | processed by Markdown.

  6. 76 |
  7. If you'd like to apply Markdown formatting only to certain posts, 77 | rather than all of them, see Jason Clark's instructions for using 78 | Markdown in conjunction with Blosxom's Meta plugin:

    79 | 80 |

    http://jclark.org/weblog/WebDev/Blosxom/Markdown.html

  8. 81 |
82 | 83 |

BBEdit

84 | 85 |

Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works 86 | with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)

87 | 88 |
    89 |
  1. Copy the "Markdown.pl" file to appropriate filters folder in your 90 | "BBEdit Support" folder. On Mac OS X, this should be:

    91 | 92 |
    BBEdit Support/Unix Support/Unix Filters/
     93 | 
    94 | 95 |

    See the BBEdit documentation for more details on the location of 96 | these folders.

    97 | 98 |

    You can rename "Markdown.pl" to whatever you wish.

  2. 99 |
  3. That's it. To use Markdown, select some text in a BBEdit document, 100 | then choose Markdown from the Filters sub-menu in the "#!" menu, or 101 | the Filters floating palette

  4. 102 |
103 | 104 |

Configuration

105 | 106 |

By default, Markdown produces XHTML output for tags with empty elements. 107 | E.g.:

108 | 109 |
<br />
110 | 
111 | 112 |

Markdown can be configured to produce HTML-style tags; e.g.:

113 | 114 |
<br>
115 | 
116 | 117 |

Movable Type

118 | 119 |

You need to use a special MTMarkdownOptions container tag in each 120 | Movable Type template where you want HTML 4-style output:

121 | 122 |
<MTMarkdownOptions output='html4'>
123 |     ... put your entry content here ...
124 | </MTMarkdownOptions>
125 | 
126 | 127 |

The easiest way to use MTMarkdownOptions is probably to put the 128 | opening tag right after your <body> tag, and the closing tag right 129 | before </body>.

130 | 131 |

To suppress Markdown processing in a particular template, i.e. to 132 | publish the raw Markdown-formatted text without translation into 133 | (X)HTML, set the output attribute to 'raw':

134 | 135 |
<MTMarkdownOptions output='raw'>
136 |     ... put your entry content here ...
137 | </MTMarkdownOptions>
138 | 
139 | 140 |

Command-Line

141 | 142 |

Use the --html4tags command-line switch to produce HTML output from a 143 | Unix-style command line. E.g.:

144 | 145 |
% perl Markdown.pl --html4tags foo.text
146 | 
147 | 148 |

Type perldoc Markdown.pl, or read the POD documentation within the 149 | Markdown.pl source code for more information.

150 | 151 |

Bugs

152 | 153 |

To file bug reports or feature requests please send email to: 154 | markdown@daringfireball.net.

155 | 156 |

Version History

157 | 158 |

1.0.1 (14 Dec 2004):

159 | 160 |
    161 |
  • Changed the syntax rules for code blocks and spans. Previously, 162 | backslash escapes for special Markdown characters were processed 163 | everywhere other than within inline HTML tags. Now, the contents 164 | of code blocks and spans are no longer processed for backslash 165 | escapes. This means that code blocks and spans are now treated 166 | literally, with no special rules to worry about regarding 167 | backslashes.

    168 | 169 |

    NOTE: This changes the syntax from all previous versions of 170 | Markdown. Code blocks and spans involving backslash characters 171 | will now generate different output than before.

  • 172 |
  • Tweaked the rules for link definitions so that they must occur 173 | within three spaces of the left margin. Thus if you indent a link 174 | definition by four spaces or a tab, it will now be a code block.

    175 | 176 |
       [a]: /url/  "Indented 3 spaces, this is a link def"
    177 | 
    178 | 
    179 |     [b]: /url/  "Indented 4 spaces, this is a code block"
    180 | 
    181 | 
    182 | 183 |

    IMPORTANT: This may affect existing Markdown content if it 184 | contains link definitions indented by 4 or more spaces.

  • 185 |
  • Added >, +, and - to the list of backslash-escapable 186 | characters. These should have been done when these characters 187 | were added as unordered list item markers.

  • 188 |
  • Trailing spaces and tabs following HTML comments and <hr/> tags 189 | are now ignored.

  • 190 |
  • Inline links using < and > URL delimiters weren't working:

    191 | 192 |
    like [this](<http://example.com/>)
    193 | 
  • 194 |
  • Added a bit of tolerance for trailing spaces and tabs after 195 | Markdown hr's.

  • 196 |
  • Fixed bug where auto-links were being processed within code spans:

    197 | 198 |
    like this: `<http://example.com/>`
    199 | 
  • 200 |
  • Sort-of fixed a bug where lines in the middle of hard-wrapped 201 | paragraphs, which lines look like the start of a list item, 202 | would accidentally trigger the creation of a list. E.g. a 203 | paragraph that looked like this:

    204 | 205 |
    I recommend upgrading to version
    206 | 8. Oops, now this line is treated
    207 | as a sub-list.
    208 | 
    209 | 210 |

    This is fixed for top-level lists, but it can still happen for 211 | sub-lists. E.g., the following list item will not be parsed 212 | properly:

    213 | 214 |
    +   I recommend upgrading to version
    215 |     8. Oops, now this line is treated
    216 |     as a sub-list.
    217 | 
    218 | 219 |

    Given Markdown's list-creation rules, I'm not sure this can 220 | be fixed.

  • 221 |
  • Standalone HTML comments are now handled; previously, they'd get 222 | wrapped in a spurious <p> tag.

  • 223 |
  • Fix for horizontal rules preceded by 2 or 3 spaces.

  • 224 |
  • <hr> HTML tags in must occur within three spaces of left 225 | margin. (With 4 spaces or a tab, they should be code blocks, but 226 | weren't before this fix.)

  • 227 |
  • Capitalized "With" in "Markdown With SmartyPants" for 228 | consistency with the same string label in SmartyPants.pl. 229 | (This fix is specific to the MT plug-in interface.)

  • 230 |
  • Auto-linked email address can now optionally contain 231 | a 'mailto:' protocol. I.e. these are equivalent:

    232 | 233 |
    <mailto:user@example.com>
    234 | <user@example.com>
    235 | 
  • 236 |
  • Fixed annoying bug where nested lists would wind up with 237 | spurious (and invalid) <p> tags.

  • 238 |
  • You can now write empty links:

    239 | 240 |
    [like this]()
    241 | 
    242 | 243 |

    and they'll be turned into anchor tags with empty href attributes. 244 | This should have worked before, but didn't.

  • 245 |
  • ***this*** and ___this___ are now turned into

    246 | 247 |
    <strong><em>this</em></strong>
    248 | 
    249 | 250 |

    Instead of

    251 | 252 |
    <strong><em>this</strong></em>
    253 | 
    254 | 255 |

    which isn't valid. (Thanks to Michel Fortin for the fix.)

  • 256 |
  • Added a new substitution in _EncodeCode(): s/\$/$/g; This 257 | is only for the benefit of Blosxom users, because Blosxom 258 | (sometimes?) interpolates Perl scalars in your article bodies.

  • 259 |
  • Fixed problem for links defined with urls that include parens, e.g.:

    260 | 261 |
    [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)
    262 | 
    263 | 264 |

    "Chomsky" was being erroneously treated as the URL's title.

  • 265 |
  • At some point during 1.0's beta cycle, I changed every sub's 266 | argument fetching from this idiom:

    267 | 268 |
    my $text = shift;
    269 | 
    270 | 271 |

    to:

    272 | 273 |
    my $text = shift || return '';
    274 | 
    275 | 276 |

    The idea was to keep Markdown from doing any work in a sub 277 | if the input was empty. This introduced a bug, though: 278 | if the input to any function was the single-character string 279 | "0", it would also evaluate as false and return immediately. 280 | How silly. Now fixed.

  • 281 |
282 | 283 |

Donations

284 | 285 |

Donations to support Markdown's development are happily accepted. See: 286 | http://daringfireball.net/projects/markdown/ for details.

287 | 288 |

Copyright and License

289 | 290 |

Copyright (c) 2003-2004 John Gruber
291 | http://daringfireball.net/
292 | All rights reserved.

293 | 294 |

Redistribution and use in source and binary forms, with or without 295 | modification, are permitted provided that the following conditions are 296 | met:

297 | 298 |
    299 |
  • Redistributions of source code must retain the above copyright notice, 300 | this list of conditions and the following disclaimer.

  • 301 |
  • Redistributions in binary form must reproduce the above copyright 302 | notice, this list of conditions and the following disclaimer in the 303 | documentation and/or other materials provided with the distribution.

  • 304 |
  • Neither the name "Markdown" nor the names of its contributors may 305 | be used to endorse or promote products derived from this software 306 | without specific prior written permission.

  • 307 |
308 | 309 |

This software is provided by the copyright holders and contributors "as 310 | is" and any express or implied warranties, including, but not limited 311 | to, the implied warranties of merchantability and fitness for a 312 | particular purpose are disclaimed. In no event shall the copyright owner 313 | or contributors be liable for any direct, indirect, incidental, special, 314 | exemplary, or consequential damages (including, but not limited to, 315 | procurement of substitute goods or services; loss of use, data, or 316 | profits; or business interruption) however caused and on any theory of 317 | liability, whether in contract, strict liability, or tort (including 318 | negligence or otherwise) arising in any way out of the use of this 319 | software, even if advised of the possibility of such damage.

320 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/mstest-0.1/markdown-readme.text: -------------------------------------------------------------------------------- 1 | Markdown 2 | ======== 3 | 4 | Version 1.0.1 - Tue 14 Dec 2004 5 | 6 | by John Gruber 7 | 8 | 9 | 10 | Introduction 11 | ------------ 12 | 13 | Markdown is a text-to-HTML conversion tool for web writers. Markdown 14 | allows you to write using an easy-to-read, easy-to-write plain text 15 | format, then convert it to structurally valid XHTML (or HTML). 16 | 17 | Thus, "Markdown" is two things: a plain text markup syntax, and a 18 | software tool, written in Perl, that converts the plain text markup 19 | to HTML. 20 | 21 | Markdown works both as a Movable Type plug-in and as a standalone Perl 22 | script -- which means it can also be used as a text filter in BBEdit 23 | (or any other application that supporst filters written in Perl). 24 | 25 | Full documentation of Markdown's syntax and configuration options is 26 | available on the web: . 27 | (Note: this readme file is formatted in Markdown.) 28 | 29 | 30 | 31 | Installation and Requirements 32 | ----------------------------- 33 | 34 | Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century. 35 | Markdown also requires the standard Perl library module `Digest::MD5`. 36 | 37 | 38 | ### Movable Type ### 39 | 40 | Markdown works with Movable Type version 2.6 or later (including 41 | MT 3.0 or later). 42 | 43 | 1. Copy the "Markdown.pl" file into your Movable Type "plugins" 44 | directory. The "plugins" directory should be in the same directory 45 | as "mt.cgi"; if the "plugins" directory doesn't already exist, use 46 | your FTP program to create it. Your installation should look like 47 | this: 48 | 49 | (mt home)/plugins/Markdown.pl 50 | 51 | 2. Once installed, Markdown will appear as an option in Movable Type's 52 | Text Formatting pop-up menu. This is selectable on a per-post basis. 53 | Markdown translates your posts to HTML when you publish; the posts 54 | themselves are stored in your MT database in Markdown format. 55 | 56 | 3. If you also install SmartyPants 1.5 (or later), Markdown will offer 57 | a second text formatting option: "Markdown with SmartyPants". This 58 | option is the same as the regular "Markdown" formatter, except that 59 | automatically uses SmartyPants to create typographically correct 60 | curly quotes, em-dashes, and ellipses. See the SmartyPants web page 61 | for more information: 62 | 63 | 4. To make Markdown (or "Markdown with SmartyPants") your default 64 | text formatting option for new posts, go to Weblog Config -> 65 | Preferences. 66 | 67 | Note that by default, Markdown produces XHTML output. To configure 68 | Markdown to produce HTML 4 output, see "Configuration", below. 69 | 70 | 71 | ### Blosxom ### 72 | 73 | Markdown works with Blosxom version 2.x. 74 | 75 | 1. Rename the "Markdown.pl" plug-in to "Markdown" (case is 76 | important). Movable Type requires plug-ins to have a ".pl" 77 | extension; Blosxom forbids it. 78 | 79 | 2. Copy the "Markdown" plug-in file to your Blosxom plug-ins folder. 80 | If you're not sure where your Blosxom plug-ins folder is, see the 81 | Blosxom documentation for information. 82 | 83 | 3. That's it. The entries in your weblog will now automatically be 84 | processed by Markdown. 85 | 86 | 4. If you'd like to apply Markdown formatting only to certain posts, 87 | rather than all of them, see Jason Clark's instructions for using 88 | Markdown in conjunction with Blosxom's Meta plugin: 89 | 90 | 91 | 92 | 93 | ### BBEdit ### 94 | 95 | Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works 96 | with BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.) 97 | 98 | 1. Copy the "Markdown.pl" file to appropriate filters folder in your 99 | "BBEdit Support" folder. On Mac OS X, this should be: 100 | 101 | BBEdit Support/Unix Support/Unix Filters/ 102 | 103 | See the BBEdit documentation for more details on the location of 104 | these folders. 105 | 106 | You can rename "Markdown.pl" to whatever you wish. 107 | 108 | 2. That's it. To use Markdown, select some text in a BBEdit document, 109 | then choose Markdown from the Filters sub-menu in the "#!" menu, or 110 | the Filters floating palette 111 | 112 | 113 | 114 | Configuration 115 | ------------- 116 | 117 | By default, Markdown produces XHTML output for tags with empty elements. 118 | E.g.: 119 | 120 |
121 | 122 | Markdown can be configured to produce HTML-style tags; e.g.: 123 | 124 |
125 | 126 | 127 | ### Movable Type ### 128 | 129 | You need to use a special `MTMarkdownOptions` container tag in each 130 | Movable Type template where you want HTML 4-style output: 131 | 132 | 133 | ... put your entry content here ... 134 | 135 | 136 | The easiest way to use MTMarkdownOptions is probably to put the 137 | opening tag right after your `` tag, and the closing tag right 138 | before ``. 139 | 140 | To suppress Markdown processing in a particular template, i.e. to 141 | publish the raw Markdown-formatted text without translation into 142 | (X)HTML, set the `output` attribute to 'raw': 143 | 144 | 145 | ... put your entry content here ... 146 | 147 | 148 | 149 | ### Command-Line ### 150 | 151 | Use the `--html4tags` command-line switch to produce HTML output from a 152 | Unix-style command line. E.g.: 153 | 154 | % perl Markdown.pl --html4tags foo.text 155 | 156 | Type `perldoc Markdown.pl`, or read the POD documentation within the 157 | Markdown.pl source code for more information. 158 | 159 | 160 | 161 | Bugs 162 | ---- 163 | 164 | To file bug reports or feature requests please send email to: 165 | markdown@daringfireball.net. 166 | 167 | 168 | 169 | Version History 170 | --------------- 171 | 172 | 1.0.1 (14 Dec 2004): 173 | 174 | + Changed the syntax rules for code blocks and spans. Previously, 175 | backslash escapes for special Markdown characters were processed 176 | everywhere other than within inline HTML tags. Now, the contents 177 | of code blocks and spans are no longer processed for backslash 178 | escapes. This means that code blocks and spans are now treated 179 | literally, with no special rules to worry about regarding 180 | backslashes. 181 | 182 | **NOTE**: This changes the syntax from all previous versions of 183 | Markdown. Code blocks and spans involving backslash characters 184 | will now generate different output than before. 185 | 186 | + Tweaked the rules for link definitions so that they must occur 187 | within three spaces of the left margin. Thus if you indent a link 188 | definition by four spaces or a tab, it will now be a code block. 189 | 190 | [a]: /url/ "Indented 3 spaces, this is a link def" 191 | 192 | [b]: /url/ "Indented 4 spaces, this is a code block" 193 | 194 | **IMPORTANT**: This may affect existing Markdown content if it 195 | contains link definitions indented by 4 or more spaces. 196 | 197 | + Added `>`, `+`, and `-` to the list of backslash-escapable 198 | characters. These should have been done when these characters 199 | were added as unordered list item markers. 200 | 201 | + Trailing spaces and tabs following HTML comments and `
` tags 202 | are now ignored. 203 | 204 | + Inline links using `<` and `>` URL delimiters weren't working: 205 | 206 | like [this]() 207 | 208 | + Added a bit of tolerance for trailing spaces and tabs after 209 | Markdown hr's. 210 | 211 | + Fixed bug where auto-links were being processed within code spans: 212 | 213 | like this: `` 214 | 215 | + Sort-of fixed a bug where lines in the middle of hard-wrapped 216 | paragraphs, which lines look like the start of a list item, 217 | would accidentally trigger the creation of a list. E.g. a 218 | paragraph that looked like this: 219 | 220 | I recommend upgrading to version 221 | 8. Oops, now this line is treated 222 | as a sub-list. 223 | 224 | This is fixed for top-level lists, but it can still happen for 225 | sub-lists. E.g., the following list item will not be parsed 226 | properly: 227 | 228 | + I recommend upgrading to version 229 | 8. Oops, now this line is treated 230 | as a sub-list. 231 | 232 | Given Markdown's list-creation rules, I'm not sure this can 233 | be fixed. 234 | 235 | + Standalone HTML comments are now handled; previously, they'd get 236 | wrapped in a spurious `

` tag. 237 | 238 | + Fix for horizontal rules preceded by 2 or 3 spaces. 239 | 240 | + `


` HTML tags in must occur within three spaces of left 241 | margin. (With 4 spaces or a tab, they should be code blocks, but 242 | weren't before this fix.) 243 | 244 | + Capitalized "With" in "Markdown With SmartyPants" for 245 | consistency with the same string label in SmartyPants.pl. 246 | (This fix is specific to the MT plug-in interface.) 247 | 248 | + Auto-linked email address can now optionally contain 249 | a 'mailto:' protocol. I.e. these are equivalent: 250 | 251 | 252 | 253 | 254 | + Fixed annoying bug where nested lists would wind up with 255 | spurious (and invalid) `

` tags. 256 | 257 | + You can now write empty links: 258 | 259 | [like this]() 260 | 261 | and they'll be turned into anchor tags with empty href attributes. 262 | This should have worked before, but didn't. 263 | 264 | + `***this***` and `___this___` are now turned into 265 | 266 | this 267 | 268 | Instead of 269 | 270 | this 271 | 272 | which isn't valid. (Thanks to Michel Fortin for the fix.) 273 | 274 | + Added a new substitution in `_EncodeCode()`: s/\$/$/g; This 275 | is only for the benefit of Blosxom users, because Blosxom 276 | (sometimes?) interpolates Perl scalars in your article bodies. 277 | 278 | + Fixed problem for links defined with urls that include parens, e.g.: 279 | 280 | [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky) 281 | 282 | "Chomsky" was being erroneously treated as the URL's title. 283 | 284 | + At some point during 1.0's beta cycle, I changed every sub's 285 | argument fetching from this idiom: 286 | 287 | my $text = shift; 288 | 289 | to: 290 | 291 | my $text = shift || return ''; 292 | 293 | The idea was to keep Markdown from doing any work in a sub 294 | if the input was empty. This introduced a bug, though: 295 | if the input to any function was the single-character string 296 | "0", it would also evaluate as false and return immediately. 297 | How silly. Now fixed. 298 | 299 | 300 | 301 | Donations 302 | --------- 303 | 304 | Donations to support Markdown's development are happily accepted. See: 305 | for details. 306 | 307 | 308 | 309 | Copyright and License 310 | --------------------- 311 | 312 | Copyright (c) 2003-2004 John Gruber 313 | 314 | All rights reserved. 315 | 316 | Redistribution and use in source and binary forms, with or without 317 | modification, are permitted provided that the following conditions are 318 | met: 319 | 320 | * Redistributions of source code must retain the above copyright notice, 321 | this list of conditions and the following disclaimer. 322 | 323 | * Redistributions in binary form must reproduce the above copyright 324 | notice, this list of conditions and the following disclaimer in the 325 | documentation and/or other materials provided with the distribution. 326 | 327 | * Neither the name "Markdown" nor the names of its contributors may 328 | be used to endorse or promote products derived from this software 329 | without specific prior written permission. 330 | 331 | This software is provided by the copyright holders and contributors "as 332 | is" and any express or implied warranties, including, but not limited 333 | to, the implied warranties of merchantability and fitness for a 334 | particular purpose are disclaimed. In no event shall the copyright owner 335 | or contributors be liable for any direct, indirect, incidental, special, 336 | exemplary, or consequential damages (including, but not limited to, 337 | procurement of substitute goods or services; loss of use, data, or 338 | profits; or business interruption) however caused and on any theory of 339 | liability, whether in contract, strict liability, or tort (including 340 | negligence or otherwise) arising in any way out of the use of this 341 | software, even if advised of the possibility of such damage. 342 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/!readme.txt: -------------------------------------------------------------------------------- 1 |  2 | iterates through all the test files in a given folder and generates file-based output 3 | this is essentially the same as running the unit tests, but with diff-able results 4 | 5 | two files should be present for each test: 6 | 7 | test_name.text -- input (raw markdown) 8 | test_name.html -- output (expected cooked html output from reference markdown engine) 9 | 10 | this file will be generated if, and ONLY IF, the expected output does not match the actual output: 11 | 12 | test_name.xxxx.actual.html -- actual output (actual cooked html output from our markdown c# engine) 13 | -- xxxx is the 16-bit CRC checksum of the file contents; this is included 14 | so you can tell if the contents of a failing test have changed 15 | 16 | Contents 17 | ======== 18 | 19 | Pandoc edge condition tests from http://code.google.com/p/pandoc/wiki/PandocVsMarkdownPl -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/failure-to-escape-less-than.html: -------------------------------------------------------------------------------- 1 |

x<max(a,b)

2 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/failure-to-escape-less-than.text: -------------------------------------------------------------------------------- 1 | x 2 |
3 | text 4 |
5 |
-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/nested-divs.text: -------------------------------------------------------------------------------- 1 | 
2 |
3 | text 4 |
5 |
-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/nested-emphasis.html: -------------------------------------------------------------------------------- 1 |

bold in italics

-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/nested-emphasis.text: -------------------------------------------------------------------------------- 1 | ***bold** in italics* -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/unordered-list-and-horizontal-rules.text: -------------------------------------------------------------------------------- 1 | + item 1 2 | 3 | + item 2 4 | 5 | * * * * * -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/unordered-list-followed-by-ordered-list.text: -------------------------------------------------------------------------------- 1 | This should be an unordered list followed by an ordered one: 2 | 3 | - foo 4 | - bar 5 | 6 | 1. first 7 | 1. second -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/pandoc/unpredictable-sublists.text: -------------------------------------------------------------------------------- 1 | (Courtesy of Allan Odgaard) 2 | 3 | * item 1 4 | * item 1a 5 | * item 2 6 | * item 2a 7 | * item 2b 8 | * item 2c 9 | * item 3 10 | 11 | And 12 | 13 | 8. item 1 14 | 9. item 2 15 | 10. item 2a -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/!readme.txt: -------------------------------------------------------------------------------- 1 |  2 | iterates through all the test files in a given folder and generates file-based output 3 | this is essentially the same as running the unit tests, but with diff-able results 4 | 5 | two files should be present for each test: 6 | 7 | test_name.text -- input (raw markdown) 8 | test_name.html -- output (expected cooked html output from reference markdown engine) 9 | 10 | this file will be generated if, and ONLY IF, the expected output does not match the actual output: 11 | 12 | test_name.xxxx.actual.html -- actual output (actual cooked html output from our markdown c# engine) 13 | -- xxxx is the 16-bit CRC checksum of the file contents; this is included 14 | so you can tell if the contents of a failing test have changed 15 | 16 | Contents 17 | ======== 18 | 19 | see http://six.pairlist.net/pipermail/markdown-discuss/2009-February/001526.html 20 | 21 | "another testsuite I made for testing PHP Markdown which should probably 22 | apply to any Markdown parser (the PHP Markdown testsuite)" 23 | 24 | NB: these tests are quite tough, many complex edge conditions -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Backslash escapes.html: -------------------------------------------------------------------------------- 1 |

Tricky combinaisons:

backslash with \-- two dashes

backslash with \> greater than

\[test](not a link)

\*no emphasis*

-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Backslash escapes.text: -------------------------------------------------------------------------------- 1 | Tricky combinaisons: backslash with \\-- two dashes backslash with \\> greater than \\\[test](not a link) \\\*no emphasis* -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Code Spans.html: -------------------------------------------------------------------------------- 1 |

From <!-- to --> 2 | on two lines.

3 | 4 |

From <!-- 5 | to --> 6 | on three lines.

7 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Code Spans.text: -------------------------------------------------------------------------------- 1 | From `` 2 | on two lines. 3 | 4 | From `` 6 | on three lines. 7 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Code block in a list item.html: -------------------------------------------------------------------------------- 1 |
    2 |
  • List Item:

    3 | 4 |
    code block
     5 | 
     6 | with a blank line
     7 | 
    8 | 9 |

    within a list item.

  • 10 |
-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Code block in a list item.text: -------------------------------------------------------------------------------- 1 | 2 | * List Item: 3 | 4 | code block 5 | 6 | with a blank line 7 | 8 | within a list item. -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Email auto links.html: -------------------------------------------------------------------------------- 1 |

michel.fortin@michelf.com

2 | 3 |

International domain names: help@tūdaliņ.lv

4 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Email auto links.text: -------------------------------------------------------------------------------- 1 | 2 | 3 | International domain names: -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Emphasis.html: -------------------------------------------------------------------------------- 1 |

Combined emphasis:

2 | 3 |
    4 |
  1. test test
  2. 5 |
  3. test test
  4. 6 |
  5. test test
  6. 7 |
  7. test test
  8. 8 |
  9. test test
  10. 9 |
  11. test test
  12. 10 |
  13. test test
  14. 11 |
  15. test test
  16. 12 |
  17. test test
  18. 13 |
  19. test test
  20. 14 |
  21. test test
  22. 15 |
  23. test test
  24. 16 |
  25. test test
  26. 17 |
  27. test test
  28. 18 |
  29. test test
  30. 19 |
  31. test test
  32. 20 |
21 | 22 |

Incorrect nesting:

23 | 24 |
    25 |
  1. *test test* test
  2. 26 |
  3. _test test_ test
  4. 27 |
  5. **test test* test*
  6. 28 |
  7. __test test_ test_
  8. 29 |
  9. test *test test*
  10. 30 |
  11. test _test test_
  12. 31 |
  13. test test test
  14. 32 |
  15. test test test
  16. 33 |
34 | 35 |

No emphasis:

36 | 37 |
    38 |
  1. test* test *test
  2. 39 |
  3. test** test **test
  4. 40 |
  5. test_ test _test
  6. 41 |
  7. test__ test __test
  8. 42 |
43 | 44 |

Middle-word emphasis (asterisks):

45 | 46 |
    47 |
  1. ab
  2. 48 |
  3. ab
  4. 49 |
  5. abc
  6. 50 |
  7. ab
  8. 51 |
  9. ab
  10. 52 |
  11. abc
  12. 53 |
54 | 55 |

Middle-word emphasis (underscore):

56 | 57 |
    58 |
  1. ab
  2. 59 |
  3. ab
  4. 60 |
  5. abc
  6. 61 |
  7. ab
  8. 62 |
  9. ab
  10. 63 |
  11. abc
  12. 64 |
65 | 66 |

mypreciousfile.txt

67 | 68 |

Tricky Cases

69 | 70 |

E**. Test TestTestTest

71 | 72 |

E**. Test Test Test Test

73 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Emphasis.text: -------------------------------------------------------------------------------- 1 | Combined emphasis: 2 | 3 | 1. ***test test*** 4 | 2. ___test test___ 5 | 3. *test **test*** 6 | 4. **test *test*** 7 | 5. ***test* test** 8 | 6. ***test** test* 9 | 7. ***test* test** 10 | 8. **test *test*** 11 | 9. *test **test*** 12 | 10. _test __test___ 13 | 11. __test _test___ 14 | 12. ___test_ test__ 15 | 13. ___test__ test_ 16 | 14. ___test_ test__ 17 | 15. __test _test___ 18 | 16. _test __test___ 19 | 20 | 21 | Incorrect nesting: 22 | 23 | 1. *test **test* test** 24 | 2. _test __test_ test__ 25 | 3. **test *test** test* 26 | 4. __test _test__ test_ 27 | 5. *test *test* test* 28 | 6. _test _test_ test_ 29 | 7. **test **test** test** 30 | 8. __test __test__ test__ 31 | 32 | 33 | 34 | No emphasis: 35 | 36 | 1. test* test *test 37 | 2. test** test **test 38 | 3. test_ test _test 39 | 4. test__ test __test 40 | 41 | 42 | 43 | Middle-word emphasis (asterisks): 44 | 45 | 1. *a*b 46 | 2. a*b* 47 | 3. a*b*c 48 | 4. **a**b 49 | 5. a**b** 50 | 6. a**b**c 51 | 52 | 53 | Middle-word emphasis (underscore): 54 | 55 | 1. _a_b 56 | 2. a_b_ 57 | 3. a_b_c 58 | 4. __a__b 59 | 5. a__b__ 60 | 6. a__b__c 61 | 62 | my_precious_file.txt 63 | 64 | 65 | ## Tricky Cases 66 | 67 | E**. **Test** TestTestTest 68 | 69 | E**. **Test** Test Test Test 70 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Headers.html: -------------------------------------------------------------------------------- 1 |

Header

2 | 3 |

Header

4 | 5 |

Header

6 | 7 |
8 | 9 |

Header

10 | 11 |

Paragraph

12 | 13 |

Header

14 | 15 |

Paragraph

16 | 17 |

Header

18 | 19 |

Paragraph

20 | 21 |
22 | 23 |

Paragraph

24 | 25 |

Header

26 | 27 |

Paragraph

28 | 29 |

Paragraph

30 | 31 |

Header

32 | 33 |

Paragraph

34 | 35 |

Paragraph

36 | 37 |

Header

38 | 39 |

Paragraph

40 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Headers.text: -------------------------------------------------------------------------------- 1 | Header ====== Header ------ ### Header 2 | 3 | - - - 4 | 5 | Header ====== Paragraph Header ------ Paragraph ### Header Paragraph 6 | 7 | - - - 8 | 9 | Paragraph Header ====== Paragraph Paragraph Header ------ Paragraph Paragraph ### Header Paragraph -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Horizontal Rules.html: -------------------------------------------------------------------------------- 1 |

Horizontal rules:

2 | 3 |
4 | 5 |
6 | 7 |
8 | 9 |
10 | 11 |
12 | 13 |

Not horizontal rules (testing for a bug in 1.0.1j):

14 | 15 |

+++

16 | 17 |

,,,

18 | 19 |

===

20 | 21 |

???

22 | 23 |

AAA

24 | 25 |

jjj

26 | 27 |

j j j

28 | 29 |

n n n

30 | 31 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Horizontal Rules.text: -------------------------------------------------------------------------------- 1 | Horizontal rules: 2 | 3 | - - - 4 | 5 | * * * 6 | 7 | *** 8 | 9 | --- 10 | 11 | ___ 12 | 13 | Not horizontal rules (testing for a bug in 1.0.1j): 14 | 15 | +++ 16 | 17 | ,,, 18 | 19 | === 20 | 21 | ??? 22 | 23 | AAA 24 | 25 | jjj 26 | 27 | j j j 28 | 29 | n n n 30 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML (Simple).html: -------------------------------------------------------------------------------- 1 |

With some attributes:

2 | 3 |
4 | foo 5 |
6 | 7 |
9 | foo 10 |
11 | 12 |

Hr's:

13 | 14 |
-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML (Simple).text: -------------------------------------------------------------------------------- 1 | With some attributes: 2 | 3 |
4 | foo 5 |
6 | 7 |
9 | foo 10 |
11 | 12 | Hr's: 13 | 14 |
16 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML (Span).html: -------------------------------------------------------------------------------- 1 |

ACINACS

2 | 3 |

SB 4 | SB

-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML (Span).text: -------------------------------------------------------------------------------- 1 | ACINACS 2 | 3 | SB 4 | SB -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML comments.html: -------------------------------------------------------------------------------- 1 |

Paragraph one.

2 | 3 | 4 | 5 |

Paragraph two.

6 | 7 | 8 | 9 |

The end.

10 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Inline HTML comments.text: -------------------------------------------------------------------------------- 1 | Paragraph one. 2 | 3 | 4 | 5 | Paragraph two. 6 | 7 | 8 | 9 | The end. 10 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Ins & del.html: -------------------------------------------------------------------------------- 1 |

Here is a block tag ins:

2 | 3 | 4 |

Some text

5 |
6 | 7 |

And here it is inside a paragraph.

8 | 9 |

And here it is in the middle of a paragraph.

10 | 11 | 12 |

Some text

13 |
14 | 15 |

And here is ins as a paragraph.

16 | 17 |

And here it is in the middle of a paragraph.

18 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Ins & del.text: -------------------------------------------------------------------------------- 1 | Here is a block tag ins: 2 | 3 | 4 |

Some text

5 |
6 | 7 | And here it is inside a paragraph. 8 | 9 | And here it is in the middle of a paragraph. 10 | 11 | 12 |

Some text

13 |
14 | 15 | And here is ins as a paragraph. 16 | 17 | And here it is in the middle of a paragraph. 18 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Links, inline style.html: -------------------------------------------------------------------------------- 1 |

silly URL w/ angle brackets.

2 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Links, inline style.text: -------------------------------------------------------------------------------- 1 | [silly URL w/ angle brackets](). 2 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/MD5 Hashes.html: -------------------------------------------------------------------------------- 1 |

Character Escapes

2 | 3 |

The MD5 value for + is "26b17225b626fb9238849fd60eabdf60".

4 | 5 |

HTML Blocks

6 | 7 |

test

8 | 9 |

The MD5 value for <p>test</p> is:

10 | 11 |

6205333b793f34273d75379350b36826

12 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/MD5 Hashes.text: -------------------------------------------------------------------------------- 1 | # Character Escapes 2 | 3 | The MD5 value for `+` is "26b17225b626fb9238849fd60eabdf60". 4 | 5 | # HTML Blocks 6 | 7 |

test

8 | 9 | The MD5 value for `

test

` is: 10 | 11 | 6205333b793f34273d75379350b36826 -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Nesting.html: -------------------------------------------------------------------------------- 1 |

Valid nesting:

2 | 3 |

Link

4 | 5 |

Link

6 | 7 |

Link

8 | 9 |

Invalid nesting:

10 | 11 |

[Link](url)

12 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Nesting.text: -------------------------------------------------------------------------------- 1 | Valid nesting: 2 | 3 | **[Link](url)** 4 | 5 | [**Link**](url) 6 | 7 | **[**Link**](url)** 8 | 9 | Invalid nesting: 10 | 11 | [[Link](url)](url) -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/PHP-Specific Bugs.html: -------------------------------------------------------------------------------- 1 |

This tests for a bug where quotes escaped by PHP when using 2 | preg_replace with the /e modifier must be correctly unescaped 3 | (hence the _UnslashQuotes function found only in PHP Markdown).

4 | 5 |

Headers below should appear exactly as they are typed (no backslash 6 | added or removed).

7 | 8 |

Header "quoted\" again \""

9 | 10 |

Header "quoted\" again \""

11 | 12 |

Header "quoted\" again \""

13 | 14 |

Test with tabs for _Detab:

15 | 16 |
Code    'block' with    some    "tabs"  and "quotes"
17 | 
18 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/PHP-Specific Bugs.text: -------------------------------------------------------------------------------- 1 | This tests for a bug where quotes escaped by PHP when using 2 | `preg_replace` with the `/e` modifier must be correctly unescaped 3 | (hence the `_UnslashQuotes` function found only in PHP Markdown). 4 | 5 | 6 | 7 | Headers below should appear exactly as they are typed (no backslash 8 | added or removed). 9 | 10 | Header "quoted\" again \\"" 11 | =========================== 12 | 13 | Header "quoted\" again \\"" 14 | --------------------------- 15 | 16 | ### Header "quoted\" again \\"" ### 17 | 18 | 19 | 20 | Test with tabs for `_Detab`: 21 | 22 | Code 'block' with some "tabs" and "quotes" 23 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Parens in URL.html: -------------------------------------------------------------------------------- 1 |

Inline link 1 with parens.

2 | 3 |

Inline link 2 with parens.

4 | 5 |

Inline link 3 with non-escaped parens.

6 | 7 |

Inline link 4 with non-escaped parens.

8 | 9 |

Reference link 1 with parens.

10 | 11 |

Reference link 2 with parens.

-------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Parens in URL.text: -------------------------------------------------------------------------------- 1 | [Inline link 1 with parens](/url\(test\) "title"). 2 | 3 | [Inline link 2 with parens]( "title"). 4 | 5 | [Inline link 3 with non-escaped parens](/url(test) "title"). 6 | 7 | [Inline link 4 with non-escaped parens]( "title"). 8 | 9 | [Reference link 1 with parens][1]. 10 | 11 | [Reference link 2 with parens][2]. 12 | 13 | [1]: /url(test) "title" 14 | [2]: "title" 15 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Tight blocks.html: -------------------------------------------------------------------------------- 1 |

Paragraph and no space: 2 | * ciao

3 | 4 |

Paragraph and 1 space: 5 | * ciao

6 | 7 |

Paragraph and 3 spaces: 8 | * ciao

9 | 10 |

Paragraph and 4 spaces: 11 | * ciao

12 | 13 |

Paragraph before header:

14 | 15 |

Header

16 | 17 |

Paragraph before blockquote:

18 | 19 |
20 |

Some quote.

21 |
22 | -------------------------------------------------------------------------------- /MarkingbirdTests/testfiles/php-markdown/Tight blocks.text: -------------------------------------------------------------------------------- 1 | Paragraph and no space: * ciao Paragraph and 1 space: * ciao Paragraph and 3 spaces: * ciao Paragraph and 4 spaces: * ciao Paragraph before header: #Header Paragraph before blockquote: >Some quote. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | (Note: I am no longer actively working on or maintaining Markingbird. If anyone wants to take on the responsibility of ongoing maintenance, please fork this repo and let me know, and I'll direct people to your fork.) 2 | 3 | # Markingbird: A Markdown Processor in Swift 4 | 5 | This library provides a [Markdown](http://daringfireball.net/projects/markdown/) processor written in [Swift](https://developer.apple.com/swift/) for OS X and iOS. It is a translation/port of the [MarkdownSharp](https://code.google.com/p/markdownsharp/) processor used by [Stack Overflow](http://blog.stackoverflow.com/2009/12/introducing-markdownsharp/). 6 | 7 | The port currently passes all of the test cases in MarkdownSharp's `SimpleTests`, `ConfigTest`, and `MDTestTests` test suites. However, it has not been extensively tested or used in production applications. If you find issues, please submit bug reports and fixes. 8 | 9 | ## How To Use It 10 | 11 | The Xcode project packages the library as a Cocoa framework. However, as all the code is in the file `Markingbird/Markdown.swift`, the easiest way to use it is to simply copy that file into your own projects. 12 | 13 | Typically, an app obtains some Markdown-formatted text somehow (read from a file, entered by a user, etc.), creates a `Markdown` object, and then calls its `transform(String) -> String` method to generate HTML. 14 | 15 | ```swift 16 | // If using Markingbird framework, import the module. 17 | // (If Markdown.swift is in your target, this is unneeded.) 18 | import Markingbird 19 | 20 | let inputText: String = getMarkdownFormatTextSomehow() 21 | 22 | // Note: must use `var` rather than `let` because the 23 | // Markdown struct mutates itself during processing 24 | var markdown = Markdown() 25 | let outputHtml: String = markdown.transform(inputText) 26 | 27 | // Use MarkdownOptions to enable non-default features 28 | var options = MarkdownOptions() 29 | options.autoHyperlink = true 30 | options.autoNewlines = true 31 | options.emptyElementSuffix = ">" 32 | options.encodeProblemUrlCharacters = true 33 | options.linkEmails = false 34 | options.strictBoldItalic = true 35 | var fancyMarkdown = Markdown(options: options) 36 | let fancyOutput = fancyMarkdown.transform(inputText) 37 | ``` 38 | 39 | A single `Markdown` instance can be used multiple times. However, it is not safe to use the `Markdown` class or its instances simultaneously from multiple threads, due to unsynchronized use of shared static data. 40 | 41 | ## To-Do 42 | 43 | - Eliminate all uses of `!` to force-unwrap Optionals (use safer `if let`, `??` or pattern-matching instead) 44 | - Re-examine the ways that characters and substrings are processed (the current implementation is a mish-mash of `String` and `NSString` bridging) 45 | - Eliminate mutable class-level state and add whatever synchronization is necessary to make it safe to use Markingbird instances in different threads. 46 | - Create sample apps for OS X and iOS. 47 | 48 | ## Implementation Notes 49 | 50 | For the most part, the code is a straightforward line-by-line translation of the C# code into Swift. Nothing has been done to make the code more "Swift-like" (whatever that means) or to improve the design. The C# code is itself a translation of Perl and PHP code, and the result is a bit of a mess. It is not a good example of Swift code, nor a good example of how to process Markdown. (It's really not a good example of anything.) 51 | 52 | Aside from changes necessary for compatibility with Swift syntax and semantics, these are the only stylistic changes made during the translation: 53 | 54 | - Lowercase identifiers for properties and methods 55 | - Indentation and brace style matching Xcode's defaults and examples in _The Swift Programming Language_ guide 56 | - Keyword arguments 57 | - Use of `let` instead of `var` where possible 58 | - Minimal use of Optional types (only used where the C# code explicitly uses or checks for `null`) 59 | - Use of Swift string interpolation where the C# code uses `String.Format()` 60 | 61 | When the Swift language and its standard library stabilize, it might make sense to reimplement this library to take advantage of advanced Swift features, but for now a simple translation of a mature implementation in a similar programming language is desirable as it is unlikely to break as Swift evolves. 62 | 63 | A `Markdown` processor is implemented as a `struct`. It might be preferable to implement it as a `class`, because it mutates itself during processing. However, the C# implementation uses a lot of class-level data members, and Swift does not yet support `class` variables in classes. Swift does support `static` members in `structs`, so it made sense to use them. Whenever Swift does support class variables, the `struct` vs. `class` decision should be revisited. 64 | 65 | To ease translation from C# to Swift, the private types `MarkdownRegex`, `MarkdownRegexOptions`, and `MarkdownRegexMatch` wrap Cocoa's `NSRegularExpression` class with interfaces similar to those of .NET's `Regex`, `RegexOptions`, and `Match` types. 66 | 67 | The implementation uses many complex regular expressions. The C# version declares these using _verbatim string literals_ that span multiple lines and eliminate the need to escape special characters. Unfortunately, Swift does not allow string literals to span multiple lines, and requires escaping of all special characters. To translate the multi-line regular expression strings to Swift in a faithful and readable way, the `String.join` method is used to concatenate an array of lines copied from the original C# source. For example: 68 | 69 | ```c# 70 | // Original C# source 71 | string attr = @" 72 | (?> # optional tag attributes 73 | \s # starts with whitespace 74 | (?> 75 | [^>""/]+ # text outside quotes 76 | | 77 | /+(?!>) # slash not followed by > 78 | | 79 | ""[^""]*"" # text inside double quotes (tolerate >) 80 | | 81 | '[^']*' # text inside single quotes (tolerate >) 82 | )* 83 | )? 84 | "; 85 | ``` 86 | 87 | ```swift 88 | // Translated to Swift 89 | let attr = "\n".join([ 90 | "(?> # optional tag attributes", 91 | " \\s # starts with whitespace", 92 | " (?>", 93 | " [^>\"/]+ # text outside quotes", 94 | " |", 95 | " /+(?!>) # slash not followed by >", 96 | " |", 97 | " \"[^\"]*\" # text inside double quotes (tolerate >)", 98 | " |", 99 | " '[^']*' # text inside single quotes (tolerate >)", 100 | " )*", 101 | ")?" 102 | ]) 103 | ``` 104 | 105 | The following transformations were made to the C# verbatim string literals to make them legal Swift literals and to conform to `NSRegularExpression`'s regular expression syntax: 106 | 107 | - Convert each `\` to `\\` 108 | - Convert each `""` to `\"` 109 | - Convert each `[ ]` (a set containing a single space) to `\\p{Z}` 110 | - In expressions that used `String.Format`, convert each `{{` to `{` and each `}}` to `}` 111 | 112 | 113 | --------------------------------------------------------------------------------