Blazing fast Markdown / CommonMark rendering in Swift, built upon cmark.

Overview

Down

Build Status MIT licensed CocoaPods Swift 5 macOS iOS tvOS Linux Code Coverage

Blazing fast Markdown (CommonMark) rendering in Swift, built upon cmark v0.29.0.

Is your app using it? Let us know!

If you're looking for iwasrobbed/Down, you found it! Rob Phillips, the originator of this repository, has transferred it to me as I will be the primary maintainer from now on. Thanks to Rob for bringing Down as far as it has come and for entrusting me with its care.

All existing references to iwasrobbed/Down should redirect to this repository. However, It is recommended to update those urls to point to this repository.

Maintainers

Installation

Note: Swift support is summarized in the table below.

Swift Version Tag
Swift 5.1 >= 0.9.0
Swift 5.0 >= 0.8.1
Swift 4 >= 0.4.x
Swift 3 0.3.x

now on the master branch and any tag >= 0.8.1 (Swift 4 is >= 0.4.x, Swift 3 is 0.3.x)

Quickly install using CocoaPods:

pod 'Down'

Install using Carthage:

github "johnxnguyen/Down"

Due to limitations in Carthage regarding platform specification, you need to define the platform with Carthage.

e.g.

carthage update --platform iOS

Install using Swift Package Manager:

To add Down to your project, select File ā†’ Swift Packages ā†’ Add Package Dependency and enter the GitHub URL for Down. See Adding Package Dependencies to Your App for detailed instructions.

Or manually install:

  1. Clone this repository
  2. Drag and drop the Down project into your workspace file, adding the framework in the embedded framework section
  3. Build and run your app
  4. ?
  5. Profit

Robust Performance

cmark can render a Markdown version of War and Peace in the blink of an eye (127 milliseconds on a ten year old laptop, vs. 100-400 milliseconds for an eye blink). In our benchmarks, cmark is 10,000 times faster than the original Markdown.pl, and on par with the very fastest available Markdown processors.

The library has been extensively fuzz-tested using american fuzzy lop. The test suite includes pathological cases that bring many other Markdown parsers to a crawl (for example, thousands-deep nested bracketed text or block quotes).

Output Formats

  • Web View (see DownView class)
  • HTML
  • XML
  • LaTeX
  • groff man
  • CommonMark Markdown
  • NSAttributedString
  • AST (abstract syntax tree)

View Rendering

The DownView class offers a very simple way to parse a UTF-8 encoded string with Markdown and convert it to a web view that can be added to any view:

let downView = try? DownView(frame: self.view.bounds, markdownString: "**Oh Hai**") {
    // Optional callback for loading finished
}
// Now add to view or constrain w/ Autolayout
// Or you could optionally update the contents at some point:
try? downView?.update(markdownString:  "## [Google](https://google.com)") {
    // Optional callback for loading finished
}

Meta example of rendering this README:

Example gif

Parsing API

The Down struct has everything you need if you just want out-of-the-box setup for parsing and conversion.

let down = Down(markdownString: "## [Down](https://github.com/johnxnguyen/Down)")

// Convert to HTML
let html = try? down.toHTML()
// "<h2><a href=\"https://github.com/johnxnguyen/Down\">Down</a></h2>\n"

// Convert to XML
let xml = try? down.toXML()
// "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE document SYSTEM \"CommonMark.dtd\">\n<document xmlns=\"http://commonmark.org/xml/1.0\">\n  <heading level=\"2\">\n    <link destination=\"https://github.com/johnxnguyen/Down\" title=\"\">\n      <text>Down</text>\n    </link>\n  </heading>\n</document>\n"

// Convert to groff man
let man = try? down.toGroff()
// ".SS\nDown (https://github.com/johnxnguyen/Down)\n"

// Convert to LaTeX
let latex = try? down.toLaTeX()
// "\\subsection{\\href{https://github.com/johnxnguyen/Down}{Down}}\n"

// Convert to CommonMark Markdown
let commonMark = try? down.toCommonMark()
// "## [Down](https://github.com/johnxnguyen/Down)\n"

// Convert to an attributed string
let attributedString = try? down.toAttributedString()
// NSAttributedString representation of the rendered HTML;
// by default, uses a stylesheet that matches NSAttributedString's default font,
// but you can override this by passing in your own, using the 'stylesheet:' parameter.

// Convert to abstract syntax tree
let ast = try? down.toAST()
// Returns pointer to AST that you can manipulate

Rendering Granularity

If you'd like more granularity for the output types you want to support, you can create your own struct conforming to at least one of the renderable protocols:

  • DownHTMLRenderable
  • DownXMLRenderable
  • DownLaTeXRenderable
  • DownGroffRenderable
  • DownCommonMarkRenderable
  • DownASTRenderable
  • DownAttributedStringRenderable

Example:

public struct MarkdownToHTML: DownHTMLRenderable {
    /**
     A string containing CommonMark Markdown
    */
    public var markdownString: String

    /**
     Initializes the container with a CommonMark Markdown string which can then be rendered as HTML using `toHTML()`

     - parameter markdownString: A string containing CommonMark Markdown

     - returns: An instance of Self
     */
    @warn_unused_result
    public init(markdownString: String) {
        self.markdownString = markdownString
    }
}

Configuration of DownView

DownView can be configured with a custom bundle using your own HTML / CSS or to do things like supporting Dynamic Type or custom fonts, etc. It's completely configurable.

This option can be found in DownView's instantiation function.

Prevent zoom

The default implementation of the DownView allows for zooming in the rendered content. If you want to disable this, then youā€™ll need to instantiate the DownView with a custom bundle where the viewport in index.html has been assigned user-scalable=no. More info can be found here.

Options

Each protocol has options that will influence either rendering or parsing:

/**
 Default options
*/
public static let `default` = DownOptions(rawValue: 0)

// MARK: - Rendering Options

/**
 Include a `data-sourcepos` attribute on all block elements
*/
public static let sourcePos = DownOptions(rawValue: 1 << 1)

/**
 Render `softbreak` elements as hard line breaks.
*/
public static let hardBreaks = DownOptions(rawValue: 1 << 2)

/**
 Suppress raw HTML and unsafe links (`javascript:`, `vbscript:`,
 `file:`, and `data:`, except for `image/png`, `image/gif`,
 `image/jpeg`, or `image/webp` mime types).  Raw HTML is replaced
 by a placeholder HTML comment. Unsafe links are replaced by
 empty strings. Note that this option is provided for backwards
 compatibility, but safe mode is now the default.
*/
public static let safe = DownOptions(rawValue: 1 << 3)

/**
 Allow raw HTML and unsafe links. Note that safe mode is now
 the default, and the unsafe option must be used if rendering
 of raw HTML and unsafe links is desired.
*/
public static let unsafe = DownOptions(rawValue: 1 << 17)

// MARK: - Parsing Options

/**
 Normalize tree by consolidating adjacent text nodes.
*/
public static let normalize = DownOptions(rawValue: 1 << 4)

/**
 Validate UTF-8 in the input before parsing, replacing illegal
 sequences with the replacement character U+FFFD.
*/
public static let validateUTF8 = DownOptions(rawValue: 1 << 5)

/**
 Convert straight quotes to curly, --- to em dashes, -- to en dashes.
*/
public static let smart = DownOptions(rawValue: 1 << 6)

/**
 Combine smart typography with HTML rendering.
*/
public static let smartUnsaFe = DownOptions(rawValue: (1 << 17) + (1 << 6))

Supports

Swift; iOS 9+, tvOS 9+, macOS 10.11+

Markdown Specification

Down is built upon the CommonMark specification.

A little help from my friends

Please feel free to fork and create a pull request for bug fixes or improvements, being sure to maintain the general coding style, adding tests, and adding comments as necessary.

Credit

This library is a wrapper around cmark, which is built upon the CommonMark Markdown specification.

cmark is Copyright (c) 2014, John MacFarlane. View full license.

Comments
  • [Attributed Strings] Create default `Styler` for attributed string rendering

    [Attributed Strings] Create default `Styler` for attributed string rendering

    We introduced a new AST renderer in https://github.com/iwasrobbed/Down/pull/132

    Next, we should create a default Styler which people can easily override so they can get up and running with attributed string rendering

    help wanted feature request Down 
    opened by iwasrobbed 28
  • [Feature] Create default `Styler` for attributed string rendering

    [Feature] Create default `Styler` for attributed string rendering

    • Follow-up to #132
    • Closes #138
    • Closes #179

    Whatā€™s in this PR?

    Itā€™s finally here! This PR contains a base implementation of the Styler protocol introduce in https://github.com/iwasrobbed/Down/pull/132. With this default implementation, it will quick and easy to render attributed strings via the AST. My hope is that the implementation is flexible and broad enough to cover the majority of styling needs.

    Overview

    I did my best to ensure that all block elements preserved the styling of inline elements, which themselves also preserve other inline elements.

    List formatting was particularly tricky, but I managed to support right aligned item markers up to a specified width as well as indentation for nested lists.

    As a bonus, code blocks are rendered in colored background container, just like in Github (more on that below).

    Configurability

    The Styler supports three main axes of configurable attributes: fonts, text color and paragraph styling. These different types of attributes are grouped together into collections: FontCollection, ColorCollection, ParagraphStyleCollection. This allows the user to easily specify related attributes in a single place. For example, one font collection could be for static fonts, another for dynamic fonts. Or separate color collections for light and dark mode.

    These collections are further grouped together into the DownStylerConfiguration struct, so that different configurations can be swapped for different rendering styles. The configuration also contains a group of other options, used to configure the appearance of the custom attributes.

    Custom Attributes

    Unfortunately, not all markdown elements can be visually represented using an NSAttributedString. These include the stripes for block quotes, the horizontal rule for thematic breaks, and the inset background container for code blocks. In order to render these elements, I defined some custom attributes.

    In order to render these attributes, a custom layout manager is required. The DownLayoutManager can be wired up to an existing text view subclass to support custom attributes, or alternatively one could use the DownTextView, which is a preconfigured TextKit stack that will automatically render markdown content (with custom attributes) whenever the text property is set.

    Down Text View & Debug Text View

    While working on the implementation I used a variation of DownLayoutManager that draws the boundaries of line fragments. Line fragments are the bounding rectangles in which lines are laid out. The DownDebugLayoutManager will indicate the line rect fragments (the rect containing the line) in red. The used line rect fragments (the rect enclosing the text within a line fragment) are drawn in blue.

    Iā€™ve exposed DownDebugLayoutManager and DownDebugTextView because theyā€™re useful tools to help specify the properties affecting paragraph styling.

    API Breaking Changes

    Some of the API declared in https://github.com/iwasrobbed/Down/pull/132 needed to be adjusted to grant the Styler more information to work with. These include adding arguments for the nest depth for lists and quotes, the prefix length for list items, and a new style method for the list item prefix.

    Note

    Images arenā€™t yet supported (they appear just like links), but Iā€™d like to add the support next.

    Inline code elements donā€™t have colored backgrounds yet, but I may add support for that too at a later date.

    Finally, having mostly worked with iOS, I developed this primarily from an iOS point of view. Nonetheless, the default styler works across the other platforms too.

    API breaker 
    opened by johnxnguyen 21
  • [Feature] Create API for parsing to AST and NSAttributedString

    [Feature] Create API for parsing to AST and NSAttributedString

    What's In This PR?

    This PR introduces the ability to traverse the abstract syntax tree generated by cmark, which will lead to the construction of an NSAttributedString without the need to render html in a web view.

    • Closes https://github.com/iwasrobbed/Down/issues/134
    • Closes https://github.com/iwasrobbed/Down/issues/100
    • Closes https://github.com/iwasrobbed/Down/issues/121

    How Does It Work?

    The Node protocol represents a wrapper around the cmark_node type. There is a concrete class for each type of cmark_node, which exposes the relevant properties for that type.

    The Visitor protocol describes an object that is able to traverse the syntax tree. This approach is quite flexible, inasmuch that arbitrary data can be generated from the tree using a concrete implementation of this protocol. For example, we could define two different visitors to generate an NSAttributedString: one that renders the styled text, and another that does the same, but also includes the markdown syntax.

    AttributedStringVisitor is a concrete visitor implementation that generates an NSMutableAttributedString. As it visits each nodes it adds the necessary line breaks and textual formatting and applies the visual attributes. It does not apply the attributes directly, but delegates this task to a Styler.

    The Styler protocol declares a styling method for each type of node. Each method receives a reference to the NSMutableAttributedString as well as potentially additional information which may be needed (header size, urls etc.).

    A concrete Styler can choose exactly how the attributes should be applied. For example, one styler could allow headers to contain bold or italic styles, while another styler could prohibit this by overwriting any such attributes that may have been previously applied to the header.

    Notes

    I haven't provided a concrete styler as this is quite an involved task and I think it would be best to address this in a separate PR, if you are interested in it. From my experience the hardest part to get right is the paragraph styling for nested blocks such as lists and block quotes.

    I would like to update the readme and possibly the demo to elucidate this feature (this could also be done in the separate PR).

    opened by johnxnguyen 21
  • [Carthage] Missing required module 'libcmark'

    [Carthage] Missing required module 'libcmark'

    Please help prevent duplicate issues before submitting a new one:

    • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

    We had this issue for example project (https://github.com/iwasrobbed/Down/issues/57) but solution was related to only example project, but not all other cases.

    Report

    What did you do?

    1. Install the framework via carthage or manually to a project
    2. Move sources to another directory (remove/rename it). (For carthage - Carthage/Checkout, for manual installing - directory with sources)

    What did you expect to happen?

    The project is compiled and worked without any errors

    What happened instead?

    "Missing required module 'libcmark'" error is displayed.

    Investigation Why does it happen? Seems like when a framework project contains a module with C code and as result a modulemap to this code, then result framework will contain links to the same C code with absolute paths. You can see that inside Down.framework/Modules/Down.swiftmodule/. Just open any swiftmodule file with any text editor and look for old modulemap path. I mean, this C code/headers(maybe just headers, not sure about that) should be placed at the same place for using the framework, otherwise framework won't find this C-module (in this case - cmark)

    Workaround Only workaround what I've found is to copy cmark folder(folder with C code) inside your project (where you have to use Down.framework) and configure Import Paths to this directory. Then, when Down.framework have to find cmark module, it will use the project settings (module is configured and load to the project already). So, either do not remove Checkout directory for carthage (because framework will look for cmark module there) and as result do not use any caches for carthage (like rome), or add cmark directory to your project and configure Import Paths.

    Bridging-Header solution If we remove using modulemap and add Bridging-Header to the project, then this case will work only when we don't have Checkouts folder. But at the same time, it won't work if sources are there (if you build it through carthage and do not remove Checkouts directory). In that case you will have Failed to import bridging header error when trying to build your project.

    Carthage workaround-available 
    opened by AlexIzh 16
  • Xcode 8.3 warnings

    Xcode 8.3 warnings

    Please help prevent duplicate issues before submitting a new one:

    • [X] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    It's just me or everyone also have 5 warnings in the new Xcode 8.3? All of them apparently are in the cmark code btw.

    screen shot 2017-04-05 at 14 39 00

    The first 4 apparently can be fixed by removing this 4 files from the build phase, the other one is a type problem

    help wanted 
    opened by lucasecf 13
  • [Attributed Strings] Unordered list items with a single line appear further indented than those with multiple lines when using a custom font

    [Attributed Strings] Unordered list items with a single line appear further indented than those with multiple lines when using a custom font

    Please help prevent duplicate issues before submitting a new one:

    • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    What did you do?

    Render a markdown string with an unordered list with a custom font. The custom font is used in the same size for the body as well as the listItemPrefix. The text is rendered via a UILabel.

    What did you expect to happen?

    The bullet points and list items to be vertically aligned.

    What happened instead?

    List items with a single line appear further indented than those which have multiple lines.

    More

    I've looked at the code and it does seem as ListItemParagraphStyler is in charge for formatting all kinds of lists. I do not understand exactly how that is supposed to work tho for unordered lists as it doesn't seem to consider bullet points as a prefix. But I think that alone might be already problematic, in particular when a custom, non-monospaced font is used for listItemPrefix.

    On a side note: I've tried to reproduce this in a snapshot test, but I've troubles getting them to run as expected in the first place. First Carthage failed to build the snapshot testing framework in a usable format, now all tests are failing. Any instructions around that?

    opened by mrackwitz 11
  • Line breaks between list items are not parsed correctly

    Line breaks between list items are not parsed correctly

    Please help prevent duplicate issues before submitting a new one:

    • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    What did you do?

    I am trying to parse the following markdown example:

    # First Example
    
    - first item
    - second item
    
    # Second Example
    
    - first item
    
    - second item
    

    What did you expect to happen?

    Most markdown renderers (e.g. Github) insert a line break between list items in Second Example.

    What happened instead?

    But Down library does parse both first and second example same way. Here is the output of DebugVisitor:

    Document
        ā†³ Heading - L1
            ā†³ Text - First Example
        ā†³ List - type: Bullet
            ā†³ Item
                ā†³ Paragraph
                    ā†³ Text - first item
            ā†³ Item
                ā†³ Paragraph
                    ā†³ Text - second item
        ā†³ Heading - L1
            ā†³ Text - Second Example
        ā†³ List - type: Bullet
            ā†³ Item
                ā†³ Paragraph
                    ā†³ Text - first item
            ā†³ Item
                ā†³ Paragraph
                    ā†³ Text - second item
    

    I do understand that you use cmark library for parsing markdown nodes, but maybe I am missing something? Maybe some configuration options?

    Or should I report this issue to cmark library repo?

    opened by ealymbaev 11
  • [Pods] Only include files in source_files that can be compiled

    [Pods] Only include files in source_files that can be compiled

    These warnings are thrown by the compiler when including Down as a cocoapod:

    screen shot 2018-04-25 at 11 52 23

    By excluding files that should not be compiled from spec.source_files, we can prevent those warnings.

    opened by njdehoog 11
  • [Feature] Custom list prefixes for AttributedStringVisitor

    [Feature] Custom list prefixes for AttributedStringVisitor

    After investigation, I've tried to find the least intrusive way to add the feature of custom list prefixes for AttributedStringVisitor. I've decided to go for ListItemPrefixgenerator changes, as fitting the feature in the styler was not possible.

    The PR is not changing the current behavior, but opening a bit the API so one can provide another implementation. See below for an example:

    Definition of a custom ListPrefixGenerator:

    public class CustomListItemPrefixGeneratorBuilder: ListItemPrefixGeneratorBuilder {
        public func build(listType: List.ListType, numberOfItems: Int, nestDepth: Int) -> ListItemPrefixGenerator {
            return CustomListItemPrefixGenerator(listType: listType, numberOfItems: numberOfItems, nestDepth: nestDepth)
        }
        
    }
    
    public class CustomListItemPrefixGenerator: ListItemPrefixGenerator {
    
        private var prefixes: IndexingIterator<[String]>
    
        required public init(listType: List.ListType, numberOfItems: Int, nestDepth: Int) {
    
            switch listType {
            case .bullet:
                let prefix = CustomListItemPrefixGenerator.unorderedPrefix(nestDepth: nestDepth)
                prefixes = [String](repeating: prefix, count: numberOfItems)
                    .makeIterator()
    
            case .ordered(let start):
                prefixes = (start..<(start + numberOfItems))
                    .map { CustomListItemPrefixGenerator.orderedPrefix(value: $0, nestDepth: nestDepth) }
                    .makeIterator()
            }
        }
    
        public func next() -> String? {
            prefixes.next()
        }
    
        private static func unorderedPrefix(nestDepth: Int) -> String {
            switch nestDepth {
            case 0:
                return "ā—"
            case 1:
                return "ā—‹"
            case _ where nestDepth >= 2:
                return "ā–ŖļøŽ"
            default:
                return "ā—"
            }
        }
    
        private static func orderedPrefix(value: Int, nestDepth: Int) -> String {
            switch value {
            case 1:
                return "1ļøāƒ£"
            case 2:
                return "2ļøāƒ£"
            case 3:
                return "3ļøāƒ£"
            default:
                return "šŸ”¢"
            }
        }
    }
    

    Usage:

    let document = try! markdown.toDocument(.default)
    let visitor = AttributedStringVisitor(
        styler: DownStyler(),
        options: .default,
        listPrefixGeneratorBuilder: CustomListItemPrefixGeneratorBuilder()
    )
    subview.attributedText = document.accept(visitor)
    

    Render: Capture dā€™Ć©cran, le 2021-04-19 Ć  15 47 27

    opened by dloic 10
  • DownStyler: Add paragraph style and font for quotes

    DownStyler: Add paragraph style and font for quotes

    • Allow customisation of quote paragraph style so we can use custom line heights and spacings.
      • overriding most of the attributes which just effect the styling of the text.
    • Make BlockBackgroundColorAttribute public so we can add the attribute in overrides of DownStyler. Use case being when adding syntax highlighting I want to override attributes of the font color and still use the DownLayoutManager to style the background colour

    Happy to explain the use cases further

    opened by foxware00 10
  • Add optional stylesheet argument for NSAttributedString renderer

    Add optional stylesheet argument for NSAttributedString renderer

    The issue that Iā€™m looking at here is somewhat subtle. Iā€™m mostly looking to start a conversation, at this point. Iā€™m not 100% sure the right way for Down.framework to approach this, so Iā€™m presenting one possible method.

    The problem

    Thereā€™s a lot of issues about fonts with NSAttributedString (#14, #15, #18, #21), so clearly thereā€™s some frustration here.

    The way Down.framework works right now is: toAttributedString() calls toHTML(), and then it makes an NSAttributedString from that. This is an easy way to get from a valid Down object to a valid NSAttributedString object, and by Downā€™s policy of ā€œitā€™s just a converterā€, this is a solution.

    The problem is with how NSAttributedStringā€™s interface works. Its default font (as documented in the API) is Helvetica 12, and so that's what you get if you make an NSAttributedString(string: ā€œhello, worldā€).

    But if you use the NSAttributedString(html:Data) initializer, this kicks it into some kind of special HTML rendering mode, which doesnā€™t use the default font. It uses a tiny serif font. Perhaps itā€™s trying to emulate Safari, which uses Times by default.

    Why Down.framework should care

    I can see 3 reasons why Down.framework should get involved here.

    First, Markdown is as much a plain text format as an HTML format. People write it like plain text, and itā€™s designed to be perfectly readable that way. (The existence of Down.framework reinforces this: it renders into 6 different formats, not just HTML.) When people call .toAttributedString(), they arenā€™t asking for ā€œan NSAttributedString of a Safari view of this Markdownā€. They want ā€œan NSAttributedString of this Markdownā€.

    Second, for every other renderer, Down (like cmark) uses the default font of that backend. The LaTeX output isnā€™t ā€œLaTeX version of a Safari rendering of Markdownā€. It uses the default LaTeX font.

    Third, itā€™s not so easy to change this from outside the library (the previous suggested approach). NSAttributedString is immutable. Itā€™s possible to make a mutable copy and update the fonts, but (AFAICT) itā€™s really a lot of work. (Personally, Iā€™d write my own Markdown renderer before I went down that path.) Fixing it from inside DownAttributedStringRenderable is easy. Why bother providing an NSAttributedString renderer, if users are going to have to rewrite it themselves to make one that works the way they want?

    One solution

    My proposed solution is straightforward. Keep using the HTML data path, but prepend a tiny stylesheet which makes it use the default NSAttributedString font. (Menlo, for monospaced text, isnā€™t a documented default of NSAttributedString, but itā€™s the standard monospaced font on macOS, and itā€™s a built-in font on every platform that Down supports.)

    This PR makes the stylesheet an optional string, so itā€™s easy to get the previous Safari-like behavior, too, if you want that:

    • To use NSAttributedStringā€™s default font, call .toAttributedString()
    • To use the Safari-style rendering, call .toAttributedString(stylesheet: "")
    • To use some other custom styles, call .toAttributedString(stylesheet: whateverYouWant)

    Iā€™m not entirely happy with this solution, but itā€™s simple, and provides the default font by default, and allows users to customize it if they need to.

    opened by kengruven 10
  • Bulleted list does not indent properly

    Bulleted list does not indent properly

    Please help prevent duplicate issues before submitting a new one:

    • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    What did you do?

    Convert markdown text to attributed string, with bulleted lists spanning multiple lines.

    • 123
    • 456 456 456 456 456 456 456 456 456 456 456 456 456 456 456
    • 789

    What did you expect to happen?

    The bulleted list to be indented properly.

    What happened instead?

    The bulleted list is not indented properly.

    Screenshot 2022-12-03 at 3 41 59 PM
    opened by ykphuah 1
  • Cannot see images in when using toAttributedString()

    Cannot see images in when using toAttributedString()

    Please help prevent duplicate issues before submitting a new one:

    • [x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    What did you do?

    I am trying to show markdown text using .toAttributedString() to UILabel

    What did you expect to happen?

    Show makrdown text with images

    What happened instead?

    Images is in the markdown is replaced with default placeholder image.

    opened by ashanatbol 1
  • SAST flagged: Unsafe Regular Expression

    SAST flagged: Unsafe Regular Expression

    Please help prevent duplicate issues before submitting a new one:

    • [ x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    Our SAST report picked up a high vulnerability within this library

    • "Potentially unsafe regular expressions. It may take a very long time to run."

    What did you do?

    Configured SAST to run within GitLab pipelines for our iOS project.

    What did you expect to happen?

    No high vulnerabilities

    What happened instead?

    Three high vulnerabilities related to this library has been flagged, this particular one is in the highlight.js file. We're on the latest version of this library and need to be able to reduce all critical and high vulnerabilities in order to ensure we're releasing secure products.

    opened by ps-vm 0
  • SAST flagged: Format strings can be influenced by an attacker

    SAST flagged: Format strings can be influenced by an attacker

    Please help prevent duplicate issues before submitting a new one:

    • [ x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    Our SAST report picked up a high vulnerability within this library

    • "If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134)."

    What did you do?

    Configured SAST to run within GitLab pipelines for our iOS project.

    What did you expect to happen?

    No high vulnerabilities

    What happened instead?

    Three high vulnerabilities related to this library has been flagged, two of which are in the cmark/config.h file. We're on the latest version of this library and need to be able to reduce all critical and high vulnerabilities in order to ensure we're releasing secure products.

    opened by ps-vm 0
  • Function Call Object Injection Sink

    Function Call Object Injection Sink

    Please help prevent duplicate issues before submitting a new one:

    • [ x] I've searched other open/closed issues for duplicates before opening up this new issue.

    Report

    Our SAST report picked up a critical vulnerability within this library

    • "Bracket object notation with user input is present, this might allow an attacker to access all properties of the object and even it's prototype, leading to possible code execution."

    What did you do?

    Configured SAST to run within GitLab pipelines for our iOS project.

    What did you expect to happen?

    No critical vulnerabilities

    What happened instead?

    One critical vulnerability related to this library has been flagged in the highlight.js file. We're on the latest version of this library and need to be able to reduce all critical and high vulnerabilities in order to ensure we're releasing secure products.

    opened by ps-vm 0
Owner
John Nguyen
John Nguyen
Rendering Markdown text natively in SwiftUI.

MarkdownView MarkdownView is a Swift Package for rendering Markdown text natively in SwiftUI. Thanks to apple/swift-markdown, it can fully compliant w

LiYanan2004 13 Oct 22, 2022
AttributedText is a Swift Āµpackage that provides NSAttributedString rendering in SwiftUI by wrapping either an NSTextView or a UITextView depending on the platform.

AttributedText AttributedText is a Swift Āµpackage that provides NSAttributedString rendering in SwiftUI by wrapping either an NSTextView or a UITextVi

null 1 Jul 18, 2022
A simple and customizable Markdown Parser for Swift

MarkdownKit MarkdownKit is a customizable and extensible Markdown parser for iOS and macOS. It supports many of the standard Markdown elements through

Bruno Oliveira 687 Dec 18, 2022
Marky Mark is a parser written in Swift that converts markdown into native views.

Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported markdown syntax is easy to extend.

M2mobi 287 Nov 29, 2022
Swift markdown library

Markdown ![Swift version](https://img.shields.io/badge/Swift-2.1 | 2.2-blue.svg) ![GitHub license](https://img.shields.io/badge/license-LGPL v3-green.

Crossroad Labs 79 Oct 9, 2022
A Pure Swift implementation of the markdown mark-up language

SmarkDown A pure Swift markdown implementation consistent with Gruber's 1.0.1 version. It is released under the BSD license so please feel free to use

Swift Studies 67 Jan 24, 2022
`resultBuilder` support for `swift-markdown`

SwiftMarkdownBuilder resultBuilder support for swift-markdown. The default way to build Markdown in swift-markdown is to use varargs initializers, e.g

DocZ 9 May 31, 2022
Leverages Apple's Swift-based Markdown parser to output NSAttributedString.

Markdownosaur ?? Markdownosaur uses Apple's excellent and relatively new Swift Markdown library to analyze a Markdown source, and then takes that anal

Christian Selig 232 Dec 20, 2022
MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

MarkdownView is a WKWebView based UI element, and internally use bootstrap, highlight.js, markdown-it.

Keita Oouchi 1.8k Dec 21, 2022
Notepad - A fully themeable iOS markdown editor with live syntax highlighting.

Notepad is just like any other UITextView, but you need to use the convenience initializer in order to use the themes. To create a new theme, copy one of the existing themes and edit the JSON.

Rudd Fawcett 802 Dec 31, 2022
Markdown in SwiftUI, and some other interesting components.

RoomTime RoomTime is a bundle of tools developed in my app RoomTime Lite. ( ?? RoomTime Lite is still in development) Features TextArea AutoWrap Markd

Chen SiWei 56 Dec 20, 2022
Markdown parser for iOS

Marky Mark Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported

M2mobi 254 Jun 11, 2021
AttributedString Markdown initializer with custom styling

AttributedString Markdown initializer with custom styling AttributedString in iOS 15 and macOS 12 comes with a Markdown initializer. But: There is no

Frank Rausch 41 Dec 19, 2022
An Objective-C framework for converting Markdown to HTML.

MMMarkdown MMMarkdown is an Objective-C framework for converting Markdown to HTML. It is compatible with OS X 10.7+, iOS 8.0+, tvOS, and watchOS. Unli

Matt Diephouse 1.2k Dec 14, 2022
Markdown syntax highlighter for iOS

Marklight Markdown syntax highlighter for iOS and macOS. Description Marklight is a drop in component to easily add realtime Markdown syntax highlight

Matteo Gavagnin 539 Dec 29, 2022
Rich Markdown editing control for iOS

MarkdownTextView Rich Markdown Editing for iOS MarkdownTextView is an iOS framework for adding rich Markdown editing capabilities. Support for Markdow

Indragie Karunaratne 676 Dec 7, 2022
Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.

SwiftyMarkdown 1.0 SwiftyMarkdown converts Markdown files and strings into NSAttributedStrings using sensible defaults and a Swift-style syntax. It us

Simon Fairbairn 1.5k Dec 22, 2022
Markdown parser for iOS

Marky Mark Marky Mark is a parser written in Swift that converts markdown into native views. The way it looks it highly customizable and the supported

M2mobi 262 Nov 23, 2021
A Github action for creating generic run report using Markdown

create-report A Github action for creating generic run report (using Markdown!) - uses: michaelhenry/[email protected] with: report-title: "

Michael Henry 4 Apr 19, 2022