Skip to content

Commit

Permalink
[ADD] rtl bi-directional support with css and js
Browse files Browse the repository at this point in the history
  • Loading branch information
moaminsharifi committed Oct 23, 2023
1 parent cf798ae commit 673d40d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ additional-css = [
"theme/css/speaker-notes.css",
"theme/css/language-picker.css",
"theme/css/frontmatter.css",
"theme/css/rtl-bidi.css",
]
site-url = "/comprehensive-rust/"
git-repository-url = "https://github.com/google/comprehensive-rust"
Expand Down
3 changes: 3 additions & 0 deletions theme/css/rtl-bidi.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
h1,h2,h3,h4,h5,h6,p,ul,li,details,button,a,ul > li {
unicode-bidi:embed;
}
10 changes: 10 additions & 0 deletions theme/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -403,5 +403,15 @@
{{/if}}

</div>
<script>
window.addEventListener('load', function() {
const bidiNeededTags = ['h1','h2','h3','h4','h5','h6','p', 'ul', '.cookieBarInner' , 'details']
bidiNeededTags.forEach(bidiNeededTag =>{
document.querySelectorAll(bidiNeededTag).forEach(selectedTag =>{
selectedTag.setAttribute("dir", "auto")
})
})
});
</script>
</body>
</html>

0 comments on commit 673d40d

Please sign in to comment.