Skip to content

Commit

Permalink
Merge pull request #37 from bustlelabs/mobiledoc-0-3-1
Browse files Browse the repository at this point in the history
Mobiledoc 0.3.1
  • Loading branch information
mixonic authored Nov 15, 2016
2 parents 17e35de + 93cd8ba commit b4ae6e3
Show file tree
Hide file tree
Showing 7 changed files with 3,029 additions and 48 deletions.
12 changes: 7 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
---
language: node_js
node_js:
- "0.12"
- "6"

sudo: false

cache:
directories:
- node_modules
- $HOME/.yarn-cache

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"
- npm config set spin false
- npm install -g yarn
- npm install phantomjs-prebuilt
- node_modules/phantomjs-prebuilt/bin/phantomjs --version

install:
- npm install -g broccoli-cli
- npm install
- yarn

script:
- npm test
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ The Renderer constructor accepts a single object with the following optional pro
* `unknownCardHandler` [function] - Will be called when any unknown card is enountered
* `unknownAtomHandler` [function] - Will be called when any unknown atom is enountered
* `sectionElementRenderer` [object] - A map of hooks for section element rendering.
* Valid keys are P, H1, H2, H3, BLOCKQUOTE, PULL-QUOTE
* Valid keys are P, H1, H2, H3, H4, H5, H6, BLOCKQUOTE, ASIDE
* Arguments are `tagName, dom`
* A valid value is a function that returns an element
* `markupElementRenderer` [object] - A map of hooks for inline element rendering.
* Valid keys are B, I, STRONG, EM, A, U, SUB, SUP, S
* Valid keys are B, I, STRONG, EM, A, U, SUB, SUP, S, CODE
* Arguments are `tagName, dom, attributes={}`
* A valid value is a function that returns an element
* `dom` [object] - A native or [SimpleDOM](https://github.com/krisselden/simple-dom)
Expand Down Expand Up @@ -99,7 +99,7 @@ var renderer = new MobiledocDOMRenderer({
element.setAttribute('class', 'subheadline');
return element;
}
/* Valid keys are P, H1, H2, H3, BLOCKQUOTE, PULL-QUOTE */
/* Valid keys are P, H1, H2, H3, H4, H5, H6, BLOCKQUOTE, ASIDE */
}
});
var rendered = renderer.render(mobiledoc);
Expand Down
12 changes: 9 additions & 3 deletions lib/renderer-factory.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import Renderer_0_2, { MOBILEDOC_VERSION as MOBILEDOC_VERSION_0_2 } from './renderers/0-2';
import Renderer_0_3, { MOBILEDOC_VERSION as MOBILEDOC_VERSION_0_3 } from './renderers/0-3';
import Renderer_0_2, {
MOBILEDOC_VERSION as MOBILEDOC_VERSION_0_2
} from './renderers/0-2';
import Renderer_0_3, {
MOBILEDOC_VERSION_0_3_0,
MOBILEDOC_VERSION_0_3_1
} from './renderers/0-3';
import RENDER_TYPE from './utils/render-type';

/**
Expand Down Expand Up @@ -83,7 +88,8 @@
case undefined:
case null:
return new Renderer_0_2(mobiledoc, this.options).render();
case MOBILEDOC_VERSION_0_3:
case MOBILEDOC_VERSION_0_3_0:
case MOBILEDOC_VERSION_0_3_1:
return new Renderer_0_3(mobiledoc, this.options).render();
default:
throw new Error(`Unexpected Mobiledoc version "${version}"`);
Expand Down
6 changes: 4 additions & 2 deletions lib/renderers/0-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import {
ATOM_MARKER_TYPE
} from '../utils/marker-types';

export const MOBILEDOC_VERSION = '0.3.0';
export const MOBILEDOC_VERSION_0_3_0 = '0.3.0';
export const MOBILEDOC_VERSION_0_3_1 = '0.3.1';
export const MOBILEDOC_VERSION = MOBILEDOC_VERSION_0_3_0;

const IMAGE_SECTION_TAG_NAME = 'img';

Expand All @@ -36,7 +38,7 @@ function createElementFromMarkerType(dom, [tagName, attributes]=['', []]){
}

function validateVersion(version) {
if (version !== MOBILEDOC_VERSION) {
if (version !== MOBILEDOC_VERSION_0_3_0 && version !== MOBILEDOC_VERSION_0_3_1) {
throw new Error(`Unexpected Mobiledoc version "${version}"`);
}
}
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/tag-names.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ import {
import { normalizeTagName } from './dom';

const MARKUP_SECTION_TAG_NAMES = [
'p', 'h1', 'h2', 'h3', 'blockquote', 'pull-quote'
'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'pull-quote', 'aside'
].map(normalizeTagName);

const MARKUP_SECTION_ELEMENT_NAMES = [
'p', 'h1', 'h2', 'h3', 'blockquote'
'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'aside'
].map(normalizeTagName);

const LIST_SECTION_TAG_NAMES = [
'ul', 'ol'
].map(normalizeTagName);

const MARKUP_TYPES = [
'b', 'i', 'strong', 'em', 'a', 'u', 'sub', 'sup', 's'
'b', 'i', 'strong', 'em', 'a', 'u', 'sub', 'sup', 's', 'code'
].map(normalizeTagName);

function contains(array, item) {
Expand Down
Loading

0 comments on commit b4ae6e3

Please sign in to comment.