Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit bf8a179

Browse files
authored
0.9 updates (#68)
* Update for PureScript 0.9 * Update build * Add badges to README * Add installation note
1 parent f8e44e6 commit bf8a179

File tree

18 files changed

+290
-259
lines changed

18 files changed

+290
-259
lines changed

.gitignore

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/.*
22
!/.gitignore
3-
/output/
4-
/node_modules/
3+
!/.travis.yml
54
/bower_components/
6-
/tmp/
75
/node_modules/
8-
/dist/
6+
/output/

.travis.yml

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js:
5-
- 5
4+
node_js: 6
65
install:
7-
- npm install [email protected] bower -g
8-
- npm install && bower install
6+
- npm install -g bower
7+
- npm install
8+
- bower install --production
99
script:
10-
- pulp test
11-
10+
- npm run -s build
11+
- bower install
12+
- npm -s test
1213
after_success:
13-
- >-
14-
test $TRAVIS_TAG &&
15-
psc-publish > .pursuit.json &&
16-
curl -X POST http://pursuit.purescript.org/packages \
17-
-d @.pursuit.json \
18-
-H 'Accept: application/json' \
19-
-H "Authorization: token ${GITHUB_TOKEN}"
14+
- >-
15+
test $TRAVIS_TAG &&
16+
echo $GITHUB_TOKEN | pulp login &&
17+
echo y | pulp publish --no-push

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# purescript-markdown
22

3+
[![Latest release](http://img.shields.io/bower/v/purescript-markdown.svg)](https://github.com/slamdata/purescript-markdown/releases)
4+
[![Build Status](https://travis-ci.org/slamdata/purescript-markdown.svg?branch=master)](https://travis-ci.org/slamdata/purescript-markdown)
5+
[![Dependency Status](https://www.versioneye.com/user/projects/578f7ce40ca92d004c89e13e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/578f7ce40ca92d004c89e13e)
6+
37
A Purescript library for parsing SlamData's dialect of Markdown, called *SlamDown*, which is mostly a safe, clean subset of CommonMark.
48

9+
## Installation
10+
11+
```
12+
bower install purescript-markdown
13+
```
14+
515
## Usage
616

717

bower.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@
2222
"package.json"
2323
],
2424
"dependencies": {
25-
"purescript-const": "^0.5.0",
26-
"purescript-functions": "^0.1.0",
27-
"purescript-functor-compose": "^0.0.1",
28-
"purescript-hugenums": "^1.3.0",
29-
"purescript-lists": "^0.7.10",
30-
"purescript-parsing": "^0.8.0",
31-
"purescript-prelude": "^0.1.3",
32-
"purescript-strongcheck": "^0.14.4",
33-
"purescript-validation": "^0.2.1",
34-
"purescript-sets": "^0.5.7"
25+
"purescript-const": "^1.0.0",
26+
"purescript-functor-compose": "garyb/purescript-functor-compose#d37327f2daf87dd75a979840a2662d664baf3313",
27+
"purescript-hugenums": "^2.0.0",
28+
"purescript-lists": "^1.0.0",
29+
"purescript-parsing": "^1.0.0",
30+
"purescript-partial": "^1.1.2",
31+
"purescript-prelude": "^1.0.0",
32+
"purescript-sets": "^1.0.0",
33+
"purescript-strings": "^1.1.0",
34+
"purescript-strongcheck": "^1.0.0",
35+
"purescript-validation": "^1.0.0"
3536
}
3637
}

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
{
22
"private": true,
3+
"scripts": {
4+
"clean": "rimraf output && rimraf .pulp-cache",
5+
"build": "pulp build --censor-lib --strict",
6+
"test": "pulp test"
7+
},
38
"devDependencies": {
4-
"purescript": "^0.8.5"
9+
"pulp": "^9.0.1",
10+
"purescript": "^0.9.1",
11+
"purescript-psa": "^0.3.9",
12+
"rimraf": "^2.5.0"
513
}
614
}

src/Text/Markdown/SlamDown/Eval.purs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ module Text.Markdown.SlamDown.Eval
44
) where
55

66
import Prelude
7+
78
import Control.Alt ((<|>))
9+
10+
import Data.Array as A
811
import Data.Const (Const(..))
9-
import Data.Identity (Identity(..), runIdentity)
1012
import Data.Functor.Compose (Compose(..), decompose)
13+
import Data.Identity (Identity(..), runIdentity)
1114
import Data.List as L
1215
import Data.Maybe as M
1316
import Data.String as S
@@ -34,7 +37,7 @@ eval fs = everywhereM b i
3437
b SD.Block a m (SD.Block a)
3538
b (SD.CodeBlock (SD.Fenced true info) code) =
3639
SD.CodeBlock (SD.Fenced false info) <<< pure <<< SD.renderValue
37-
<$> fs.code (M.Just info) (S.joinWith "\n" (L.fromList code))
40+
<$> fs.code (M.Just info) (S.joinWith "\n" (A.fromFoldable code))
3841
b other = pure $ other
3942

4043
i SD.Inline a m (SD.Inline a)

src/Text/Markdown/SlamDown/Parser.purs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ module Text.Markdown.SlamDown.Parser
44
, validateSlamDown
55
) where
66

7-
import Prelude
7+
import Prelude hiding (min)
88

9-
import Data.Foldable (any, all)
109
import Data.Either (Either)
10+
import Data.Foldable (any, all)
11+
import Data.List ((:))
1112
import Data.List as L
1213
import Data.Maybe as M
1314
import Data.Monoid (mempty)
1415
import Data.String as S
1516
import Data.Traversable (traverse)
16-
import Data.Validation as V
17+
import Data.Validation.Semigroup as V
18+
19+
import Partial.Unsafe (unsafePartial)
1720

18-
import Text.Markdown.SlamDown.Syntax as SD
1921
import Text.Markdown.SlamDown.Parser.Inline as Inline
2022
import Text.Markdown.SlamDown.Parser.References as Ref
21-
22-
infixr 6 L.Cons as :
23-
23+
import Text.Markdown.SlamDown.Syntax as SD
2424

2525
data Container a
2626
= CText String
@@ -56,7 +56,7 @@ allChars p = all p <<< S.split ""
5656

5757
removeNonIndentingSpaces String String
5858
removeNonIndentingSpaces s
59-
| S.count (isSpace <<< S.fromChar) s < 4 = S.dropWhile (isSpace <<< S.fromChar) s
59+
| S.count (isSpace <<< S.singleton) s < 4 = S.dropWhile (isSpace <<< S.singleton) s
6060
| otherwise = s
6161

6262
isRuleChar String Boolean
@@ -74,15 +74,15 @@ isRule s =
7474
isATXHeader String Boolean
7575
isATXHeader s =
7676
let
77-
level = S.count (\c → S.fromChar c == "#") s
77+
level = S.count (\c → S.singleton c == "#") s
7878
rest = S.drop level s
7979
in
8080
level >= 1 && level <= 6 && S.take 1 rest == " "
8181

8282
splitATXHeader String { level Int, contents String }
8383
splitATXHeader s =
8484
let
85-
level = S.count (\c → S.fromChar c == "#") s
85+
level = S.count (\c → S.singleton c == "#") s
8686
contents = S.drop (level + 1) s
8787
in
8888
{ level: level
@@ -117,7 +117,7 @@ splitBlockquote ss =
117117
blockquoteContents s = S.drop (if S.take 2 s == "> " then 2 else 1) s
118118

119119
countLeadingSpaces String Int
120-
countLeadingSpaces = S.count (isSpace <<< S.fromChar)
120+
countLeadingSpaces = S.count (isSpace <<< S.singleton)
121121

122122
isBulleted String Boolean
123123
isBulleted s =
@@ -136,7 +136,7 @@ isBulleted s =
136136
isOrderedListMarker String Boolean
137137
isOrderedListMarker s =
138138
let
139-
n = S.count (isDigit <<< S.fromChar) s
139+
n = S.count (isDigit <<< S.singleton) s
140140
next = S.take 1 (S.drop n s)
141141
ls = countLeadingSpaces (S.drop (n + 1) s)
142142
in
@@ -146,14 +146,14 @@ listItemType ∷ String → SD.ListType
146146
listItemType s
147147
| isBulleted s = SD.Bullet (S.take 1 s)
148148
| otherwise =
149-
let n = S.count (isDigit <<< S.fromChar) s
149+
let n = S.count (isDigit <<< S.singleton) s
150150
in SD.Ordered (S.take 1 (S.drop n s))
151151

152152
listItemIndent String Int
153153
listItemIndent s
154154
| isBulleted s = 1 + min 4 (countLeadingSpaces (S.drop 1 s))
155155
| otherwise =
156-
let n = S.count (isDigit <<< S.fromChar) s
156+
let n = S.count (isDigit <<< S.singleton) s
157157
in n + 1 + min 4 (countLeadingSpaces (S.drop (n + 1) s))
158158

159159
isListItemLine String Boolean
@@ -207,7 +207,7 @@ splitIndentedChunks ss =
207207
isCodeFence String Boolean
208208
isCodeFence s = isSimpleFence s || (isEvaluatedCode s && isSimpleFence (S.drop 1 s))
209209
where
210-
isSimpleFence s = S.count (isFenceChar <<< S.fromChar) s >= 3
210+
isSimpleFence s = S.count (isFenceChar <<< S.singleton) s >= 3
211211

212212
isEvaluatedCode String Boolean
213213
isEvaluatedCode s = S.take 1 s == "!"
@@ -218,7 +218,7 @@ isFenceChar "`" = true
218218
isFenceChar _ = false
219219

220220
codeFenceInfo String String
221-
codeFenceInfo = S.trim <<< S.dropWhile (isFenceChar <<< S.fromChar)
221+
codeFenceInfo = S.trim <<< S.dropWhile (isFenceChar <<< S.singleton)
222222

223223
codeFenceChar String String
224224
codeFenceChar = S.take 1
@@ -240,7 +240,7 @@ splitCodeFence indent fence ss =
240240
}
241241
where
242242
isClosingFence String Boolean
243-
isClosingFence s = S.count (\c → S.fromChar c == fence) (removeNonIndentingSpaces s) >= 3
243+
isClosingFence s = S.count (\c → S.singleton c == fence) (removeNonIndentingSpaces s) >= 3
244244

245245
removeIndentTo String String
246246
removeIndentTo s = S.drop (min indent (countLeadingSpaces s)) s
@@ -289,7 +289,7 @@ parseContainers acc (L.Cons s ss)
289289
| isLinkReference (removeNonIndentingSpaces s) =
290290
let
291291
s1 = removeNonIndentingSpaces s
292-
b = Data.Maybe.Unsafe.fromJust $ Ref.parseLinkReference s1
292+
b = unsafePartial M.fromJust $ Ref.parseLinkReference s1
293293
in
294294
parseContainers (L.Cons (CLinkReference b) acc) ss
295295
| otherwise = parseContainers (L.Cons (CText s) acc) ss
@@ -372,6 +372,6 @@ tabsToSpaces = S.replace "\t" " "
372372
parseMd a. (SD.Value a) String Either String (SD.SlamDownP a)
373373
parseMd s = map SD.SlamDown bs
374374
where
375-
lines = L.toList $ S.split "\n" $ S.replace "\r" "" $ tabsToSpaces s
375+
lines = L.fromFoldable $ S.split "\n" $ S.replace "\r" "" $ tabsToSpaces s
376376
ctrs = parseContainers mempty lines
377377
bs = parseBlocks ctrs

0 commit comments

Comments
 (0)