diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a00c1..af36018 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.1.4] - 2022-05-04 + +##### Changed + +- Fixed mangling of markdown-produced HTML next to top-level text nodes when a mediamap is provided (#150) + ## [2.1.3] - 2022-04-21 ##### Changed diff --git a/README.md b/README.md index f22f88d..2001f8b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![coverage-shield-badge-1](https://img.shields.io/badge/coverage-97.85%25-brightgreen.svg) +![coverage-shield-badge-1](https://img.shields.io/badge/coverage-98.31%25-brightgreen.svg) [![npm version](https://badge.fury.io/js/enketo-transformer.svg)](http://badge.fury.io/js/enketo-transformer) [![Build Status](https://travis-ci.org/enketo/enketo-transformer.svg?branch=master)](https://travis-ci.org/enketo/enketo-transformer) [![Dependency Status](https://david-dm.org/enketo/enketo-transformer.svg)](https://david-dm.org/enketo/enketo-transformer) # Enketo Transformer diff --git a/docs/index.html b/docs/index.html index 3c734c6..1a1c36c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -62,7 +62,7 @@

-

coverage-shield-badge-1 +

coverage-shield-badge-1 npm version Build Status Dependency Status

Enketo Transformer

NodeJS library that transforms OpenRosa/ODK XForms into a format the Enketo understands. It works both as a library module, as well as a standalone app.

diff --git a/docs/module-transformer.html b/docs/module-transformer.html index 1163ed7..c5013c1 100644 --- a/docs/module-transformer.html +++ b/docs/module-transformer.html @@ -407,7 +407,7 @@

Source:
@@ -566,7 +566,7 @@

(inner) Source:
@@ -763,7 +763,7 @@

(inner)
Source:
@@ -917,7 +917,7 @@

(inne
Source:
@@ -1098,7 +1098,7 @@

(inner) _
Source:
@@ -1207,7 +1207,7 @@

(inner) _md5Source:
@@ -1368,7 +1368,7 @@

(inner) _pa
Source:
@@ -1526,7 +1526,7 @@

(inne
Source:
@@ -1723,7 +1723,7 @@

(inner) Source:
@@ -1924,7 +1924,7 @@

(inner)
Source:
@@ -2113,7 +2113,7 @@

(inner)
Source:
@@ -2314,7 +2314,7 @@

(inner) Source:
@@ -2495,7 +2495,7 @@

(inner) _t
Source:
diff --git a/docs/transformer.js.html b/docs/transformer.js.html index f2cccd4..872add2 100644 --- a/docs/transformer.js.html +++ b/docs/transformer.js.html @@ -129,11 +129,15 @@

transformer.js

} : {}; - const mediaMap = Object.fromEntries( - Object.entries(survey.media || {}).map((entry) => - entry.map(escapeURLPath) - ) - ); + let mediaMap = null; + + if (survey.media) { + mediaMap = Object.fromEntries( + Object.entries(survey.media).map((entry) => + entry.map(escapeURLPath) + ) + ); + } return _parseXml(survey.xform) .then((doc) => { @@ -547,12 +551,15 @@

transformer.js

if (original !== rendered) { if (mediaMap != null) { - const fragment = libxmljs.parseHtmlFragment(rendered); - - rendered = _replaceMediaSources( - fragment, - mediaMap - ).toString(false); + const fragment = libxmljs.parseHtmlFragment( + `<div class="temporary-root">${rendered}</div>` + ); + + rendered = _replaceMediaSources(fragment, mediaMap) + .root() + .childNodes() + .map((node) => node.toString(false)) + .join(''); } key = `$$$${index}`; diff --git a/package-lock.json b/package-lock.json index ade8f61..f1ad4a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "enketo-transformer", - "version": "2.1.3", + "version": "2.1.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2326,9 +2326,9 @@ } }, "eslint-plugin-react-hooks": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.4.0.tgz", - "integrity": "sha512-U3RVIfdzJaeKDQKEJbz5p3NW8/L80PCATJAfuojwbaEL+gBjfGdhUcGde+WGUW46Q5sr/NgxevsIiDtNXrvZaQ==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.5.0.tgz", + "integrity": "sha512-8k1gRt7D7h03kd+SAAlzXkQwWK22BnK6GKZG+FJA6BAGy22CFvl8kCIXKpVux0cCxMWDQUPqSok0LKaZ0aOcCw==", "dev": true }, "eslint-plugin-unicorn": { @@ -4093,12 +4093,6 @@ "requires": { "has-flag": "^1.0.0" } - }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", - "dev": true } } }, @@ -4697,9 +4691,9 @@ }, "dependencies": { "ansi-regex": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", - "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.1.tgz", + "integrity": "sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g==", "dev": true }, "astral-regex": { @@ -4730,9 +4724,9 @@ } }, "debug": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.3.tgz", - "integrity": "sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==", + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", "dev": true, "requires": { "ms": "2.1.2" @@ -5376,9 +5370,9 @@ } }, "nodemon": { - "version": "2.0.15", - "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.15.tgz", - "integrity": "sha512-gdHMNx47Gw7b3kWxJV64NI+Q5nfl0y5DgDbiVtShiwa7Z0IZ07Ll4RLFo6AjrhzMtoEZn5PDE3/c2AbVsiCkpA==", + "version": "2.0.16", + "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.16.tgz", + "integrity": "sha512-zsrcaOfTWRuUzBn3P44RDliLlp263Z/76FPoHFr3cFFkOz0lTPAcIw8dCzfdVIx/t3AtDYCZRCDkoCojJqaG3w==", "dev": true, "requires": { "chokidar": "^3.5.2", @@ -7460,9 +7454,9 @@ "dev": true }, "semver": { - "version": "7.3.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", - "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "version": "7.3.7", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.7.tgz", + "integrity": "sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g==", "dev": true, "requires": { "lru-cache": "^6.0.0" diff --git a/package.json b/package.json index 7a967cf..8b5c0a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "enketo-transformer", - "version": "2.1.3", + "version": "2.1.4", "description": "Library/app that transforms ODK-compliant XForms into a format that Enketo can consume", "license": "Apache-2.0", "main": "src/transformer.js", @@ -62,7 +62,7 @@ "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-react": "^7.29.4", - "eslint-plugin-react-hooks": "^4.4.0", + "eslint-plugin-react-hooks": "^4.5.0", "eslint-plugin-unicorn": "^36.0.0", "grunt": "^1.5.2", "http-server": "^13.1.0", @@ -71,7 +71,7 @@ "jsdoc-plugin-typescript": "^2.0.7", "markdown-eslint-parser": "^1.2.1", "mocha": "^9.2.2", - "nodemon": "^2.0.15", + "nodemon": "^2.0.16", "nyc": "^15.1.0", "prettier": "^2.6.2", "rimraf": "^3.0.2"