Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support IE11 #53

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 2 additions & 1 deletion js/kunai/code/cpp.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ID} from './id'

import {Logger} from 'nagato'

const arrayIncludes = require("core-js/library/fn/array/includes")

class CPP {
constructor(log, id, buf, hints) {
Expand All @@ -27,7 +28,7 @@ class CPP {

if (hints.headers) {
for (const h of hints.headers) {
if (!this.headers.includes(h)) {
if (!arrayIncludes(this.headers, h)) {
this.log.warn(`already found header '${h}' in meta tag, but it was not written in this code snippet`)
this.prepend_header(h)
this.headers.push(h)
Expand Down
74 changes: 39 additions & 35 deletions js/kunai/ui/badge.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
const sanitize = (badges) => {
let i = 0

for (let b_raw of badges) {
++i

let b = $(b_raw)
const classes = b.attr('class').split(/\s+/).map(t => t.trim())
// const clean_txt = b.text().trim().replace(/\(([^)]+)\)/, '$1')

let deprecated_or_removed = false
let cppv = null
for (const c of classes) {
const cppm = c.match(/^cpp(\d[\da-zA-Z])(.*)$/)
if (!cppm) continue

b.attr('data-cpp-version', cppm[1])
if (cppm[1].length) {
cppv = cppm[1]
console.log("ui/badge.js:3==>", badges)
try{
for (let b_raw of badges) {
++i

let b = $(b_raw)
const classes = b.attr('class').split(/\s+/).map(t => t.trim())
// const clean_txt = b.text().trim().replace(/\(([^)]+)\)/, '$1')

let deprecated_or_removed = false
let cppv = null
for (const c of classes) {
const cppm = c.match(/^cpp(\d[\da-zA-Z])(.*)$/)
if (!cppm) continue

b.attr('data-cpp-version', cppm[1])
if (cppm[1].length) {
cppv = cppm[1]
}

if (c.match(/deprecated$/)) {
deprecated_or_removed = true
b.addClass('deprecated-spec')
} else if (c.match(/removed$/)) {
deprecated_or_removed = true
b.addClass('removed-spec')
}
}

if (c.match(/deprecated$/)) {
deprecated_or_removed = true
b.addClass('deprecated-spec')
} else if (c.match(/removed$/)) {
deprecated_or_removed = true
b.addClass('removed-spec')
if (!deprecated_or_removed) {
b.addClass('added-in-spec')
}
}

if (!deprecated_or_removed) {
b.addClass('added-in-spec')
}

const lang_path = cppv ? `/lang/cpp${cppv}` : `/lang`
const lang_path = cppv ? `/lang/cpp${cppv}` : `/lang`

b.html(
$('<a>').attr('href', `${lang_path}.html`)
.append($('<i>'))
// .append($('<span>').text(clean_txt))
)
b.html(
$('<a>').attr('href', `${lang_path}.html`)
.append($('<i>'))
// .append($('<span>').text(clean_txt))
)
}
}
finally {
return i
}
return i
}

export {sanitize}
Expand Down