crossroadlabs / markdown Goto Github PK
View Code? Open in Web Editor NEWSwift markdown library
License: GNU General Public License v3.0
Swift markdown library
License: GNU General Public License v3.0
I use the library to display a "terms and conditions" text.
The generated document is cut before the end of the source text.
the debug process:
let contents = try NSString(contentsOfFile: filepath, usedEncoding: nil) as String
gives:
[...]se réserve la faculté de modifier à tout moment, de plein droit et sans formalités, les présentes CGU[...]
let md = try Markdown(string:contents)
let document = try md.document()
gives :
se réserve la faculté de modifier à tout moment, de plein droi
"
Added to Package.swift, then on swift build
:
Cloning https://github.com/crossroadlabs/CDiscount.git
HEAD is now at 207cbc3 added modulemap
Resolved version: 0.1.0
Compile Swift Module 'Markdown' (3 sources)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/.../Packages/CDiscount-0.1.0/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
Hello!
After running brew install discount
I can see that discount did properly install. However, Swift can't compile my app without using the following command:
swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib -Xswiftc -target -Xswiftc x86_64-apple-macosx10.12
I'm really new to this type of development and unfamiliar with the environment, so I am hoping this is not a real issue and is just some dummy error on my part.
This seems to be related to #3, which should have been resolved via a release for libmarkdown
. Is there a status update on that?
Do you mind providing some insight on the issue?
PS. I'm following the Server-Side Swift book by @twostraws and it's been excellent. I've reached a project in the book that uses your library and that's when I found this issue.
macOS 10.12.5
Xcode8.3.3
swift build
output➜ Project11 swift build
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
Compile Swift Module 'libc' (1 sources)
Compile Swift Module 'Polymorphic' (2 sources)
Compile Swift Module 'Jay' (21 sources)
Compile Swift Module 'PathIndexable' (2 sources)
Compile Swift Module 'SwiftSlug' (1 sources)
Compile Swift Module 'Markdown' (3 sources)
Compile Swift Module 'Spectre' (8 sources)
Compile Swift Module 'Cryptor' (10 sources)
Compile Swift Module 'KituraTemplateEngine' (1 sources)
Compile Swift Module 'SwiftyJSON' (2 sources)
Compile Swift Module 'Socket' (3 sources)
Compile Swift Module 'LoggerAPI' (1 sources)
Compile Swift Module 'Core' (29 sources)
Compile Swift Module 'HeliumLogger' (2 sources)
Compile Swift Module 'Node' (22 sources)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/zk/Developer/Server/Project11/.build/debug.yaml
-Xlinker
and -target
, but not -Xcc
➜ Project11 swift build -Xlinker -L/usr/local/lib -Xswiftc -target -Xswiftc x86_64-apple-macosx10.12
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
Compile Swift Module 'Markdown' (3 sources)
Compile Swift Module 'Jay' (21 sources)
Compile Swift Module 'libc' (1 sources)
Compile Swift Module 'Polymorphic' (2 sources)
Compile Swift Module 'PathIndexable' (2 sources)
Compile Swift Module 'SwiftSlug' (1 sources)
Compile Swift Module 'Spectre' (8 sources)
Compile Swift Module 'KituraTemplateEngine' (1 sources)
Compile Swift Module 'Cryptor' (10 sources)
Compile Swift Module 'SwiftyJSON' (2 sources)
Compile Swift Module 'Socket' (3 sources)
Compile Swift Module 'LoggerAPI' (1 sources)
Compile Swift Module 'Core' (29 sources)
Compile Swift Module 'HeliumLogger' (2 sources)
Compile Swift Module 'Node' (22 sources)
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "cdiscount.h"
^
/Users/zk/Developer/Server/Project11/.build/checkouts/CDiscount.git-4318135343521947030/cdiscount.h:22:10: error: 'mkdio.h' file not found
#include <mkdio.h>
^
/Users/zk/Developer/Server/Project11/.build/checkouts/Markdown.git--5008474681835546292/Sources/Markdown/Markdown.swift:22:8: error: could not build Objective-C module 'CDiscount'
import CDiscount
^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/zk/Developer/Server/Project11/.build/debug.yaml
➜ Project11 swift build -Xcc -I/usr/local/include -Xlinker -L/usr/local/lib -Xswiftc -target -Xswiftc x86_64-apple-macosx10.12
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
note: you may be able to install libmarkdown using your system-packager:
brew install discount
Compile Swift Module 'Markdown' (3 sources)
Compile Swift Module 'libc' (1 sources)
Compile Swift Module 'Polymorphic' (2 sources)
Compile Swift Module 'Jay' (21 sources)
Compile Swift Module 'PathIndexable' (2 sources)
Compile Swift Module 'SwiftSlug' (1 sources)
Compile Swift Module 'Spectre' (8 sources)
Compile Swift Module 'Cryptor' (10 sources)
Compile Swift Module 'KituraTemplateEngine' (1 sources)
Compile Swift Module 'SwiftyJSON' (2 sources)
Compile Swift Module 'Socket' (3 sources)
Compile Swift Module 'LoggerAPI' (1 sources)
Compile Swift Module 'Core' (29 sources)
Compile Swift Module 'HeliumLogger' (2 sources)
Compile Swift Module 'Node' (22 sources)
Compile Swift Module 'PathKit' (1 sources)
Compile Swift Module 'Stencil' (19 sources)
Compile Swift Module 'KituraStencil' (1 sources)
Compile Swift Module 'JSON' (9 sources)
Compile Swift Module 'MySQL' (11 sources)
Compile Swift Module 'SSLService' (1 sources)
Compile CHTTPParser http_parser.c
Compile CHTTPParser utils.c
Linking CHTTPParser
Compile Swift Module 'KituraNet' (34 sources)
Compile Swift Module 'Kitura' (43 sources)
Compile Swift Module 'project11' (1 sources)
Linking ./.build/debug/project11
Hi,
I tried the installation using the swift package manager, but it throws an error saying:
Empty manifest file is not supported anymore. Use `swift package init` to autogenerate.
error: The package at `....../Packages/CDiscount.git' has no Package.swift for the specific version: 0.1.0
What can I do to actually install this library?
Thanks
Hi,
I'm installing the library using Carthage, but after following all the steps and doing the import, Xcode says:
Module file was created by an older version of the compiler; rebuild 'Markdown' and try again: /Volumes/MacOSHibrido/Users/nestor/Documents/freelances/ios-10-course/TestAppLayout/Carthage/Build/Mac/Markdown.framework/Modules/Markdown.swiftmodule/x86_64.swiftmodule
I tried running:
carthage update --no-use-binaries
But then I got the following error:
*** Fetching Markdown
*** Fetching CDiscount
*** Checking out CDiscount at "0.1.0"
*** Checking out Markdown at "0.1.0"
*** xcodebuild output can be found in /var/folders/5p/16f9d01140n53_65ftsbjh4h0000gn/T/carthage-xcodebuild.R8yKD7.log
*** Building scheme "Markdown" in Markdown.xcodeproj
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
warning: no umbrella header found for target 'Markdown', module map will not be generated
warning: no umbrella header found for target 'Markdown', module map will not be generated
A shell task (/usr/bin/xcrun xcodebuild -project /Volumes/MacOSHibrido/Users/nestor/Documents/freelances/ios-10-course/TestAppLayout/Carthage/Checkouts/Markdown/Markdown.xcodeproj -scheme Markdown -configuration Release ONLY_ACTIVE_ARCH=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES clean build) failed with exit code 65:
** CLEAN FAILED **
The following build commands failed:
Check dependencies
(1 failure)
** BUILD FAILED **
The following build commands failed:
Check dependencies
(1 failure)
How do I fix this?
There's a memory leak in Markdown.swift
at line 47:
var dest = [UnsafeMutablePointer<Int8>?](repeating: UnsafeMutablePointer<Int8>.allocate(capacity: 1), count: 1)
This line is allocating space for a pointer to be returned, but in doing so is also allocating an actual pointer to one byte of memory. When fun
is called to process data and return a result, the allocated pointer is overwritten and the one-byte allocation (16 actual bytes) is lost.
Since all you need is space for a pointer here, and since the array is an array-of-optionals, you can just replace that line with this:
var dest: [UnsafeMutablePointer<Int8>?] = [nil]
No allocation, so no leak.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.