Skip to content

Instantly share code, notes, and snippets.

@ArvinH
Last active November 12, 2017 05:41
Show Gist options
  • Save ArvinH/e3bbd62fcf22f8d00c88610adaf6c888 to your computer and use it in GitHub Desktop.
Save ArvinH/e3bbd62fcf22f8d00c88610adaf6c888 to your computer and use it in GitHub Desktop.
Regex for solving order problem
diff --git a/src/components/github-htmlview.component.js b/src/components/github-htmlview.component.js
index 1d50925..83e04d3 100644
--- a/src/components/github-htmlview.component.js
+++ b/src/components/github-htmlview.component.js
@@ -204,8 +204,10 @@ export class GithubHtmlView extends Component {
/<span class="email-hidden-toggle"><a href="#">…<\/a><\/span>/g,
''
)
- .replace(/<\/summary>/g, '</summary><hidden>')
+ .replace(/<details>/g, '<details><hidden>')
.replace(/<\/details>/g, '</hidden></details>')
+ .replace(/(<details>)(<hidden>(.|\n|\r)*)(<summary>(.|\n|\r)*<\/summary>)((.|\n|\r)*)(<\/hidden><\/details>)/g,
+ '$1$4$2$6$8')
// Remove links & spans around images
.replace(/<a[^>]+><img([^>]+)><\/a>/g, '<img$1>')
.replace(/<span[^>]*><img([^>]+)><\/span>/g, '<img$1>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment