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

Commit c326aae

Browse files
authored
Merge pull request #73 from garyb/0.10-updates
Update for PureScript 0.10
2 parents fe27025 + c1d24ce commit c326aae

File tree

15 files changed

+73
-75
lines changed

15 files changed

+73
-75
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 6
4+
node_js: stable
55
install:
66
- npm install -g bower
77
- npm install

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
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)
3+
[![Latest release](http://img.shields.io/github/release/slamdata/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)
65

76
A Purescript library for parsing SlamData's dialect of Markdown, called *SlamDown*, which is mostly a safe, clean subset of CommonMark.
87

bower.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
"package.json"
2323
],
2424
"dependencies": {
25-
"purescript-const": "^1.0.0",
26-
"purescript-functor-compose": "^0.1.0",
27-
"purescript-hugenums": "^2.0.1",
28-
"purescript-lists": "^1.0.1",
29-
"purescript-parsing": "^1.0.0",
25+
"purescript-const": "^2.0.0",
26+
"purescript-functors": "^1.0.0",
27+
"purescript-lists": "^3.2.0",
28+
"purescript-parsing": "^3.0.0",
3029
"purescript-partial": "^1.1.2",
31-
"purescript-prelude": "^1.0.1",
32-
"purescript-sets": "^1.0.0",
33-
"purescript-strings": "^1.1.0",
34-
"purescript-strongcheck": "^1.1.1",
35-
"purescript-validation": "^1.0.0"
30+
"purescript-precise": "^1.0.0",
31+
"purescript-prelude": "^2.1.0",
32+
"purescript-sets": "^2.0.0",
33+
"purescript-strings": "^2.0.2",
34+
"purescript-strongcheck": "^2.0.0",
35+
"purescript-validation": "^2.0.0"
3636
}
3737
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"devDependencies": {
99
"pulp": "^9.0.1",
10-
"purescript": "^0.9.2",
10+
"purescript": "^0.10.1",
1111
"purescript-psa": "^0.3.9",
1212
"rimraf": "^2.5.4"
1313
}

src/Text/Markdown/SlamDown/Eval.purs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ import Control.Alt ((<|>))
99

1010
import Data.Array as A
1111
import Data.Const (Const(..))
12-
import Data.Functor.Compose (Compose(..), decompose)
13-
import Data.Identity (Identity(..), runIdentity)
12+
import Data.Functor.Compose (Compose(..))
13+
import Data.Identity (Identity(..))
1414
import Data.List as L
1515
import Data.Maybe as M
16+
import Data.Newtype (unwrap)
1617
import Data.String as S
1718
import Data.Traversable as T
1819

@@ -56,11 +57,11 @@ eval fs = everywhereM b i
5657
evalTextBox SD.TextBox (Compose M.Maybe SD.Expr) m (M.Maybe (SD.TextBox Identity))
5758
evalTextBox tb = T.sequence $ fs.textBox <$> asCode tb <|> pure <$> asLit tb
5859
where
59-
asLit = SD.traverseTextBox (decompose >>> (_ >>= SD.getLiteral) >>> map Identity)
60-
asCode = SD.traverseTextBox (decompose >>> (_ >>= SD.getUnevaluated) >>> map Const)
60+
asLit = SD.traverseTextBox (unwrap >>> (_ >>= SD.getLiteral) >>> map Identity)
61+
asCode = SD.traverseTextBox (unwrap >>> (_ >>= SD.getUnevaluated) >>> map Const)
6162

6263
quoteTextBox SD.TextBox Identity SD.TextBox (Compose M.Maybe SD.Expr)
63-
quoteTextBox = SD.transTextBox (runIdentity >>> SD.Literal >>> M.Just >>> Compose)
64+
quoteTextBox = SD.transTextBox (unwrap >>> SD.Literal >>> M.Just >>> Compose)
6465

6566
f (SD.RadioButtons sel opts) = do
6667
sel' ← evalExpr fs.value sel

src/Text/Markdown/SlamDown/Parser.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ isDigit "9" = true
5252
isDigit _ = false
5353

5454
allChars (String Boolean) String Boolean
55-
allChars p = all p <<< S.split ""
55+
allChars p = all p <<< S.split (S.Pattern "")
5656

5757
removeNonIndentingSpaces String String
5858
removeNonIndentingSpaces s
@@ -367,11 +367,11 @@ validateSlamDown ∷ ∀ a. SD.SlamDownP a → V.V (Array String) (SD.SlamDownP
367367
validateSlamDown (SD.SlamDown bls) = SD.SlamDown <$> traverse validateBlock bls
368368

369369
tabsToSpaces String String
370-
tabsToSpaces = S.replace "\t" " "
370+
tabsToSpaces = S.replace (S.Pattern "\t") (S.Replacement " ")
371371

372372
parseMd a. (SD.Value a) String Either String (SD.SlamDownP a)
373373
parseMd s = map SD.SlamDown bs
374374
where
375-
lines = L.fromFoldable $ S.split "\n" $ S.replace "\r" "" $ tabsToSpaces s
375+
lines = L.fromFoldable $ S.split (S.Pattern "\n") $ S.replace (S.Pattern "\r") (S.Replacement "") $ tabsToSpaces s
376376
ctrs = parseContainers mempty lines
377377
bs = parseBlocks ctrs

src/Text/Markdown/SlamDown/Parser/Inline.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ parseInlines
3939
Either String (L.List (SD.Inline a))
4040
parseInlines s =
4141
map consolidate
42-
$ lmap (\(P.ParseError {message}) → message)
42+
$ lmap P.parseErrorMessage
4343
$ P.runParser (S.joinWith "\n" $ A.fromFoldable s) inlines
4444

4545
consolidate

src/Text/Markdown/SlamDown/Parser/Utils.purs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import Prelude
1212
import Data.Either (fromRight)
1313
import Data.String (singleton)
1414
import Data.String.Regex as R
15+
import Data.String.Regex.Flags as RF
1516

1617
import Partial.Unsafe (unsafePartial)
1718

@@ -24,23 +25,14 @@ isWhitespace = R.test wsRegex <<< singleton
2425
where
2526
wsRegex R.Regex
2627
wsRegex = unsafePartial fromRight $
27-
R.regex "^\\s$" flags
28+
R.regex "^\\s$" RF.noFlags
2829

2930
isEmailAddress String Boolean
3031
isEmailAddress = R.test wsEmail
3132
where
3233
wsEmail R.Regex
3334
wsEmail = unsafePartial fromRight $
34-
R.regex """^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$""" flags
35-
36-
flags R.RegexFlags
37-
flags =
38-
{ unicode: false
39-
, sticky: false
40-
, multiline: false
41-
, ignoreCase: false
42-
, global: false
43-
}
35+
R.regex """^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$""" RF.noFlags
4436

4537
parens a. Parser String a Parser String a
4638
parens p = string "(" *> skipSpaces *> p <* skipSpaces <* string ")"

src/Text/Markdown/SlamDown/Pretty.purs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import Prelude
77

88
import Data.Array as A
99
import Data.Foldable (fold, elem)
10-
import Data.Functor.Compose (Compose, decompose)
10+
import Data.Functor.Compose (Compose)
1111
import Data.HugeNum as HN
1212
import Data.Identity (Identity(..))
1313
import Data.List as L
1414
import Data.Maybe as M
1515
import Data.Monoid (mempty)
1616
import Data.String as S
17+
import Data.Newtype (unwrap)
1718
import Data.Unfoldable as U
1819

1920
import Text.Markdown.SlamDown.Syntax as SD
@@ -35,7 +36,7 @@ overLines f = map f <<< L.concatMap lines
3536

3637
lines String L.List String
3738
lines "" = mempty
38-
lines s = L.fromFoldable $ S.split "\n" s
39+
lines s = L.fromFoldable $ S.split (S.Pattern "\n") s
3940

4041
prettyPrintBlock a. (SD.Value a) SD.Block a L.List String
4142
prettyPrintBlock bl =
@@ -102,7 +103,7 @@ prettyPrintInline il =
102103
esc l <> star <> " = " <> prettyPrintFormElement e
103104
where
104105

105-
esc s = M.maybe s (const $ "[" <> s <> "]") $ S.indexOf " " s
106+
esc s = M.maybe s (const $ "[" <> s <> "]") $ S.indexOf (S.Pattern " ") s
106107

107108
printTarget SD.LinkTarget String
108109
printTarget (SD.InlineLink url) = parens url
@@ -115,7 +116,7 @@ prettyPrintTextBoxValue t =
115116
SD.PlainText (Identity def) → def
116117
SD.Numeric (Identity def) →
117118
let s = HN.toString def in
118-
M.fromMaybe s $ S.stripSuffix "." $ HN.toString def
119+
M.fromMaybe s $ S.stripSuffix (S.Pattern ".") $ HN.toString def
119120
SD.Date (Identity def) → prettyPrintDate def
120121
SD.Time prec (Identity def) → prettyPrintTime prec def
121122
SD.DateTime prec (Identity def) → prettyPrintDateTime prec def
@@ -155,7 +156,7 @@ printIntPadded l i =
155156
prettyPrintTextBox SD.TextBox (Compose M.Maybe SD.Expr) String
156157
prettyPrintTextBox t =
157158
prettyPrintTemplate t
158-
<> M.maybe "" (\x → " (" <> prettyPrintDefault x <> ")") (SD.traverseTextBox decompose t)
159+
<> M.maybe "" (\x → " (" <> prettyPrintDefault x <> ")") (SD.traverseTextBox unwrap t)
159160
where
160161
prettyPrintTemplate f. SD.TextBox f String
161162
prettyPrintTemplate t =

src/Text/Markdown/SlamDown/Syntax/Block.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ derive instance ordBlock ∷ (Ord a) ⇒ Ord (Block a)
4848
-- | Nota bene: this does not generate any recursive structure
4949
instance arbitraryBlock ∷ (SCA.Arbitrary a, Eq a) SCA.Arbitrary (Block a) where
5050
arbitrary = do
51-
k ← Gen.chooseInt 0.0 6.0
51+
k ← Gen.chooseInt 0 6
5252
case k of
5353
0Paragraph <$> listOf SCA.arbitrary
5454
1Header <$> SCA.arbitrary <*> listOf SCA.arbitrary

0 commit comments

Comments
 (0)