Skip to content

Commit

Permalink
Merge pull request #2 from klntsky/klntsky/updates-for-v0.15
Browse files Browse the repository at this point in the history
Updates for purs v0.15
  • Loading branch information
klntsky authored May 15, 2022
2 parents 683a464 + 944cd6a commit f6e8ee9
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions jest.config.js → jest.config.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
export default {
// An array of directory names to be searched recursively up from the requiring module's location
moduleDirectories: ["node_modules", "output"],

// The test environment that will be used for testing
testEnvironment: "node",

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: ["/node_modules/", "/bower_components/"]
testPathIgnorePatterns: ["/node_modules/", "/bower_components/", "/\.spago/"]
};
17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
{
"license": "BSD-3-Clause",
"type": "module",
"scripts": {
"build": "spago build -u '--strict --stash +RTS -N2 -RTS'",
"test": "spago build && jest"
"test": "spago build && NODE_OPTIONS=--experimental-vm-modules jest"
},
"devDependencies": {
"jest": "^23.6.0",
"jest": "^25.1.0",
"markdown-it-imsize": "^2.0.1"
},
"dependencies": {
"markdown-it": "^9.0.1"
},
"jest": {
"moduleDirectories": [
"node_modules",
"output"
],
"testEnvironment": "node",
"testPathIgnorePatterns": [
"/node_modules/",
"/bower_components/",
"/\\.spago/"
]
}
}
11 changes: 6 additions & 5 deletions packages.dhall
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20211005/packages.dhall sha256:2ec351f17be14b3f6421fbba36f4f01d1681e5c7f46e0c981465c4cf222de5be
https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220507/packages.dhall
sha256:cf54330f3bc1b25a093b69bff8489180c954b43668c81288901a2ec29a08cc64

let extra =
{ jest =
{ dependencies = [ "effect", "aff", "aff-promise" ]
, repo = "https://github.com/nonbili/purescript-jest.git"
, version = "v0.5.0"
}
{ dependencies = [ "effect", "aff", "aff-promise" ]
, repo = "https://github.com/nonbili/purescript-jest.git"
, version = "018543987af27db6a3842048b6b3f5ec47609087"
}
}

in upstream // extra
12 changes: 6 additions & 6 deletions src/MarkdownIt.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
var MarkdownIt = require("markdown-it");
import MarkdownIt from "markdown-it";

exports.renderString_ = function(input) {
export function renderString_(input) {
var md = new MarkdownIt();
return md.render(input);
};

exports.newMarkdownIt_ = function(preset, opts) {
export function newMarkdownIt_(preset, opts) {
if (opts.highlight) {
const fn = opts.highlight;
opts.highlight = (str, lang) => fn(str)(lang);
}
return new MarkdownIt(preset, opts);
};

exports.render_ = function(md, input) {
export function render_(md, input) {
return md.render(input);
};

exports.renderInline_ = function(md, input) {
export function renderInline_(md, input) {
return md.renderInline(input);
};

exports.use_ = function(plugin, md) {
export function use_(plugin, md) {
return md.use(plugin);
};
12 changes: 1 addition & 11 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import Data.Tuple (Tuple(..))
import Effect (Effect)
import Effect.Class (liftEffect)
import Jest (expectToEqual, test)
import MarkdownIt (Preset(..), html, linkify, highlight, newMarkdownIt, render, renderString, use)
import Node.Globals as Globals
import MarkdownIt (Preset(..), html, linkify, highlight, newMarkdownIt, render, renderString)

cases :: Array (Tuple String String)
cases =
Expand Down Expand Up @@ -74,12 +73,3 @@ main = do
output = "<pre>js - alert()\n</pre>\n"
html <- liftEffect $ render md input
expectToEqual html output

test "use markdown-it-imsize" $ do
md <- liftEffect $ (newMarkdownIt Default $ linkify := true) >>=
use (Globals.unsafeRequire "markdown-it-imsize")
let
input = "![](src =32x32)"
output = "<p><img src=\"src\" alt=\"\" width=\"32\" height=\"32\"></p>\n"
html <- liftEffect $ render md input
expectToEqual html output

This comment has been minimized.

Copy link
@rnons

rnons May 26, 2022

Collaborator

Sorry I just saw this, why is it removed?

4 changes: 2 additions & 2 deletions test/main.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const Test = require("Test.Main");
import { main } from "Test.Main";

Test.main();
main();

0 comments on commit f6e8ee9

Please sign in to comment.