Skip to content
Merged

Develop #2224

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/public/*
/themes/*
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"plugins": [
"cypress"
"cypress",
"no-only-tests"
],
"extends": [
"plugin:cypress-dev/general",
Expand All @@ -10,5 +11,8 @@
"es6": true,
"node": true,
"cypress/globals": true
},
"rules": {
"no-only-tests/no-only-tests": "warn"
}
}
3 changes: 1 addition & 2 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ jobs:
#
- run: ls -la
- run: npm run deps
- run: npm run lint
- run: npm run lint -- --max-warnings=0
- run: npm run md-lint
- run: npm run stop-only
- run: npm test
- run: npm run build

Expand Down
7 changes: 6 additions & 1 deletion lib/raw_render.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ module.exports = function rawRender (hexo, text, options = {}) {
}

return hexo.render.renderSync({
text,
text: text.replace(/[-]{2}/g, 'rDOUBLE_DASHr'),
engine,
})
// these replacements are a temporary fix: see the comments on
// https://github.com/cypress-io/cypress-documentation/pull/935
.replace('–', '--')
.replace('—', '---')
.replace(/rDOUBLE_DASHr/g, '--')
})
}
4 changes: 0 additions & 4 deletions lib/tags/assertions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,12 @@ module.exports = function yields (hexo, args) {
const type = args[0]
const cmd = `<code>${args[1]}()</code>`

/* eslint-disable commas */
const waitAssertions = `${cmd} will automatically wait for assertions you've chained to pass`

/* eslint-disable commas */
const retryAssertions = `${cmd} will automatically {% url "retry" retry-ability %} until assertions you've chained all pass`

/* eslint-disable quotes */
const exist = `${cmd} will automatically {% url "retry" retry-ability %} until the element(s) {% url 'exist in the DOM' introduction-to-cypress#Default-Assertions %}`

/* eslint-disable quotes */
const actionable = `${cmd} will automatically wait for the element to reach an {% url 'actionable state' interacting-with-elements %}`

const render = (str) => {
Expand Down
46 changes: 26 additions & 20 deletions lib/tags/note.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Promise = require('bluebird')
const rawRender = require('../raw_render')

module.exports = function note (hexo, args, content) {
// {% note info Want to see Cypress in action? %}
Expand All @@ -22,30 +23,35 @@ module.exports = function note (hexo, args, content) {
bolt: 'bolt', // useful for tips / hints
}

const className = args.shift()

const toMarkdown = (text) =>
hexo.render.renderSync({ text, engine: 'markdown' })
rawRender(hexo, text, { engine: 'markdown' })

const stripSurroundingParagraph = (text) =>
text.replace(/^<p>/, '').replace(/<\/p>$/, '')
const stripSurroundingParagraph = (text) => {
return text.replace(/^<p>/, '').replace(/<\/p>$/, '')
}

let header = ''
const className = args.shift()
const icon = iconLookup[className]
const renderHeader = (params) => {
if (!params.length) {
return Promise.resolve('')
}

return toMarkdown(params.join(' '))
.then((content) => {
const className = args.shift()
const icon = iconLookup[className]

if (args.length) {
header += `<strong class="note-title foo">
${icon ? `<i class="fa fa-${icon}"></i>` : ''}
${stripSurroundingParagraph(toMarkdown(args.join(' ')))}
</strong>`
return `<strong class="note-title foo">
${icon ? `<i class="fa fa-${icon}"></i>` : ''}
${stripSurroundingParagraph(content)}
</strong>`
})
}

return Promise.resolve(
// these replacements are a temporary fix: see the comments on
// https://github.com/cypress-io/cypress-documentation/pull/935
toMarkdown(content)
.replace('–', '--')
.replace('—', '---')
).then((markdown) => {
return `<blockquote class="note ${className}">${header}${markdown}</blockquote>`
})
Promise.all([
toMarkdown(content),
renderHeader(args),
])
.then(([markdown, header]) => `<blockquote class="note ${className}">${header}${markdown}</blockquote>`)
}
3 changes: 2 additions & 1 deletion lib/tags/partial.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ const rawRender = require('../raw_render')

module.exports = function partial (hexo, fileName) {
const pathToFile = path.resolve('source', '_partial', `${fileName}.md`)

return new Promise((resolve, reject) => {
fs.readFile(pathToFile, (err, data) => {
if (err) reject(err)

resolve(rawRender(hexo, data.toString(), { engine: 'markdown' }))
})
})
Expand Down
Loading