Giter Site home page Giter Site logo

githawkapp / cmark-gfm-swift Goto Github PK

View Code? Open in Web Editor NEW
38.0 3.0 21.0 230 KB

An extension of GitHub's cmark fork with a Swift AST wrapper.

Home Page: http://githawk.com

License: MIT License

Ruby 0.11% Swift 4.54% Objective-C 0.03% C 75.24% C++ 20.07%
swift markdown cmark githawk

cmark-gfm-swift's Introduction

cmark-gfm-swift's People

Contributors

getaclue00 avatar lukakerr avatar maniramezan avatar rnystrom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cmark-gfm-swift's Issues

Adding Carthage support

I was unable to use cmark-gfm-swift without some extra effort. In its current state, if you use normal Carthage methodologies to include this framework (add to Linked Framework and Libraries, post-process using the Copy Carthage Frameworks script) you will get the following error when you try and import the module in a swift file:
cmark.h not found with <angled> include; use ”quotes" instead

A quick fix is to add this to XCode's HEADER_SEARCH_PATHS:
$(SRCROOT)/Carthage/Checkouts/cmark-gfm-swift/**

The correct fix is to modify the modulemap so that cmark.h (and dependencies? unsure) are included in the compiled framework. I believe that the way to do this is to go into the project's Build Phases and edit the Headers section, moving cmark.h from the Private Headers group to the Public Headers group.

Checkbox range is wrong if text has multibyte characters

This test will fail.

    func testMarkdownCheckbox_withChecked_withMultibyte() {
        let markdown = """
            - [x] テスト
            - [x] テスト2
            """
        let node = Node(markdown: markdown)!
        XCTAssertEqual(node.elements.count, 1)
        
        guard case .list(let items, _)? = node.elements.first else { fatalError() }
        // get second checkbox after multibyte characters
        guard case .paragraph(let paragraph)? = items[1].first else { fatalError() }
        guard case .checkbox(let checked, let range) = paragraph[1] else { fatalError() }

        XCTAssertEqual(markdown.substring(with: range), "[x]")
    }

The location of the checkbox should be converted into multibyte count here.
I'm not sure the best way to get the whole content of the original markdown, but this might work.

        var location = Int(cmark_node_get_checkbox_location(node))
        if let string = String(bytes: original_markdown.utf8.prefix(location), encoding:.utf8) {
            location = string.count
        }

`Info.plist` needs to be excluded from source files

Currently, Info.plist is under Source directory and gets added to Compiled Sources while it'd not needed. In addition, this would cause the new build system which is also the default in Xcode 12 to fails compiling any app using this project as a pod dependency. Following is the error thrown by build system:

error: Multiple commands produce 'path_to_build/Build/Products/Debug-iphonesimulator/cmark-gfm-swift/cmark_gfm_swift.framework/Info.plist':
1) Target 'cmark-gfm-swift' has copy command from 'path_to_project/Pods/cmark-gfm-swift/Source/Info.plist' to 'path_to_build/Build/Products/Debug-iphonesimulator/cmark-gfm-swift/cmark_gfm_swift.framework/Info.plist'
2) Target 'cmark-gfm-swift' has process command with input 'path_to_project/Pods/Target Support Files/cmark-gfm-swift/Info.plist'

Bracket syntax for links

According to spec.
There is bracket syntax for links which contain whitespaces.

However, cmark-gfm-swift does not handled it correctly.

input:
[link](</my uri>)

cmark-gfm's output:
<p><a href="/my%20uri">link</a></p>

cmark-gfm-swift's output:
<p>[link](&lt;/my uri&gt;)</p>

Add footnotes extension support

Hi, it seems that cmark-gfm supports footnotes and there is already an extension for that.
I think cmark-gfm-swift needs to support it also.

If time allows, I'm going to implement this.
Is it okay to do some PRs? or is there any extension inclusion criteria?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.