Skip to content

Commit

Permalink
feat(docs): set target=_blank to links (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
Margar1ta authored and pimenovoleg committed Sep 26, 2019
1 parent 8983db8 commit b4f9c92
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="docs-footer__wrapper">
<div class="docs-footer__text-wrapper">
<span class="docs-footer__text">© 2019 Positive Technologies</span>
<span class="docs-footer__text">Code licensed under an <a class="docs-footer__link">MIT-style License</a>.</span>
<span class="docs-footer__text">Code licensed under an <a class="docs-footer__link" href="//github.com/positive-js/mosaic/blob/master/LICENSE" target="_blank">MIT-style License</a>.</span>
</div>
<div class="docs-footer__icon">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

@mixin example-viewer-typography($config) {
.docs-example-source {
.docs-example-source, .docs-example-numbers {
@include mc-typography-level-to-styles($config, body-mono);
font-size: 14px;
}
Expand Down
11 changes: 11 additions & 0 deletions tools/gulp/tasks/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ task('docs', series(
function transformMarkdownFiles(buffer: Buffer, file: any): string {
let content = buffer.toString('utf-8');
content = tagNameStringAliaser(content);
content = setTargetBlank(content);

// Replace <!-- example(..) --> comments with HTML elements.
content = content.replace(EXAMPLE_PATTERN, (_match: string, name: string) =>
Expand Down Expand Up @@ -228,3 +229,13 @@ function setImageCaption(content: string): string {

return html;
}

function setTargetBlank(content: string): string {
let html = content;
const regex = new RegExp(`href=".[^"]*"`, 'g'); // .[^"]* - any symbol exept "
html = html.replace(regex, (match: string) =>
`${match} target="_blank"`
);

return html;
}

0 comments on commit b4f9c92

Please sign in to comment.