Skip to content

Commit

Permalink
Fix WPD at-rule detection + don't process if language is not handled …
Browse files Browse the repository at this point in the history
…+ fix plugin's page
  • Loading branch information
Golmote committed Jul 14, 2016
1 parent 36739b3 commit 2626728
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 48 deletions.
4 changes: 2 additions & 2 deletions plugins/wpd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ <h2>CSS</h2>
<pre data-src="prism.css"></pre>

<h2>HTML</h2>
<pre data-src="index.html"></pre>
<pre data-src="index.html" class="language-markup"></pre>

<h2>SVG</h2>
<pre data-src="logo.svg"></pre>
<pre data-src="logo.svg" class="language-markup"></pre>
</section>

<footer data-src="templates/footer.html" data-type="text/html"></footer>
Expand Down
93 changes: 48 additions & 45 deletions plugins/wpd/prism-wpd.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ if (
}

if (Prism.languages.css) {
Prism.languages.css.atrule.inside['atrule-id'] = /^@[\w-]+/;

// check whether the selector is an advanced pattern before extending it
if (Prism.languages.css.selector.pattern)
{
Expand Down Expand Up @@ -57,60 +55,65 @@ var language;
Prism.hooks.add('wrap', function(env) {
if ((env.type == 'tag-id'
|| (env.type == 'property' && env.content.indexOf('-') != 0)
|| (env.type == 'atrule-id'&& env.content.indexOf('@-') != 0)
|| (env.type == 'rule'&& env.content.indexOf('@-') != 0)
|| (env.type == 'pseudo-class'&& env.content.indexOf(':-') != 0)
|| (env.type == 'pseudo-element'&& env.content.indexOf('::-') != 0)
|| (env.type == 'attr-name' && env.content.indexOf('data-') != 0)
) && env.content.indexOf('<') === -1
|| (env.type == 'attr-name' && env.content.indexOf('data-') != 0)
) && env.content.indexOf('<') === -1
) {
var searchURL = 'w/index.php?fulltext&search=';
if (env.language == 'css'
|| env.language == 'scss'
|| env.language == 'markup'
) {
var searchURL = 'w/index.php?fulltext&search=';

env.tag = 'a';

var href = 'http://docs.webplatform.org/';

if (env.language == 'css' || env.language == 'scss') {
href += 'wiki/css/';

if (env.type == 'property') {
href += 'properties/';
}
else if (env.type == 'atrule-id') {
href += 'atrules/';
}
else if (env.type == 'pseudo-class') {
href += 'selectors/pseudo-classes/';
}
else if (env.type == 'pseudo-element') {
href += 'selectors/pseudo-elements/';
}
}
else if (env.language == 'markup') {
if (env.type == 'tag-id') {
// Check language
language = getLanguage(env.content) || language;

if (language) {
href += 'wiki/' + language + '/elements/';
env.tag = 'a';

var href = 'http://docs.webplatform.org/';

if (env.language == 'css' || env.language == 'scss') {
href += 'wiki/css/';

if (env.type == 'property') {
href += 'properties/';
}
else if (env.type == 'rule') {
href += 'atrules/';
}
else {
href += searchURL;
else if (env.type == 'pseudo-class') {
href += 'selectors/pseudo-classes/';
}
else if (env.type == 'pseudo-element') {
href += 'selectors/pseudo-elements/';
}
}
else if (env.type == 'attr-name') {
if (language) {
href += 'wiki/' + language + '/attributes/';
else if (env.language == 'markup') {
if (env.type == 'tag-id') {
// Check language
language = getLanguage(env.content) || language;

if (language) {
href += 'wiki/' + language + '/elements/';
}
else {
href += searchURL;
}
}
else {
href += searchURL;
else if (env.type == 'attr-name') {
if (language) {
href += 'wiki/' + language + '/attributes/';
}
else {
href += searchURL;
}
}
}

href += env.content;

env.attributes.href = href;
env.attributes.target = '_blank';
}

href += env.content;

env.attributes.href = href;
env.attributes.target = '_blank';
}
});

Expand Down
2 changes: 1 addition & 1 deletion plugins/wpd/prism-wpd.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2626728

Please sign in to comment.