diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ae82bc57..25256d205 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ All notable changes to Shiny for Python will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [UNRELEASED]
+
+### Improvements
+
+* Improved the styling and readability of markdown tables rendered by `ui.Chat()` and `ui.MarkdownStream()`. (#1973)
+
## [1.4.0] - 2025-04-08
## New features
diff --git a/js/markdown-stream/markdown-stream.ts b/js/markdown-stream/markdown-stream.ts
index 8a6a0f77d..2250631e0 100644
--- a/js/markdown-stream/markdown-stream.ts
+++ b/js/markdown-stream/markdown-stream.ts
@@ -45,28 +45,38 @@ const SVG_DOT = createSVGIcon(
``
);
-// For rendering chat output, we use typical Markdown behavior of passing through raw
-// HTML (albeit sanitizing afterwards).
-//
-// For echoing chat input, we escape HTML. This is not for security reasons but just
-// because it's confusing if the user is using tag-like syntax to demarcate parts of
-// their prompt for other reasons (like / for providing examples to the
-// chat model), and those tags simply vanish.
-const rendererEscapeHTML = new Renderer();
-rendererEscapeHTML.html = (html: string) =>
+// 'markdown' renderer (for assistant messages)
+const markdownRenderer = new Renderer();
+
+// Add some basic Bootstrap styling to markdown tables
+markdownRenderer.table = (header: string, body: string) => {
+ return `
+ ${header}
+ ${body}
+
`;
+};
+
+// 'semi-markdown' renderer (for user messages)
+const semiMarkdownRenderer = new Renderer();
+
+// Escape HTML, not for security reasons, but just because it's confusing if the user is
+// using tag-like syntax to demarcate parts of their prompt for other reasons (like
+// / for providing examples to the model), and those tags vanish.
+semiMarkdownRenderer.html = (html: string) =>
html
.replaceAll("&", "&")
.replaceAll("<", "<")
.replaceAll(">", ">")
.replaceAll('"', """)
.replaceAll("'", "'");
-const markedEscapeOpts = { renderer: rendererEscapeHTML };
function contentToHTML(content: string, content_type: ContentType) {
if (content_type === "markdown") {
- return unsafeHTML(sanitizeHTML(parse(content) as string));
+ const html = parse(content, { renderer: markdownRenderer });
+ return unsafeHTML(sanitizeHTML(html as string));
} else if (content_type === "semi-markdown") {
- return unsafeHTML(sanitizeHTML(parse(content, markedEscapeOpts) as string));
+ const html = parse(content, { renderer: semiMarkdownRenderer });
+ return unsafeHTML(sanitizeHTML(html as string));
} else if (content_type === "html") {
return unsafeHTML(sanitizeHTML(content));
} else if (content_type === "text") {
diff --git a/pyproject.toml b/pyproject.toml
index 4c2f7ba45..0a5ef7e76 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -100,7 +100,7 @@ dev = [
"isort>=5.10.1",
"libsass>=0.23.0",
"brand_yml>=0.1.0",
- "pyright>=1.1.398",
+ "pyright==1.1.398",
"pre-commit>=2.15.0",
"wheel",
"matplotlib",
diff --git a/shiny/www/py-shiny/markdown-stream/markdown-stream.js b/shiny/www/py-shiny/markdown-stream/markdown-stream.js
index da5179e5c..de3b69251 100644
--- a/shiny/www/py-shiny/markdown-stream/markdown-stream.js
+++ b/shiny/www/py-shiny/markdown-stream/markdown-stream.js
@@ -1,13 +1,13 @@
-var ya=Object.create;var zn=Object.defineProperty;var Xi=Object.getOwnPropertyDescriptor;var Ta=Object.getOwnPropertyNames;var Na=Object.getPrototypeOf,wa=Object.prototype.hasOwnProperty;var W=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Sa=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ta(e))!wa.call(t,r)&&r!==n&&zn(t,r,{get:()=>e[r],enumerable:!(i=Xi(e,r))||i.enumerable});return t};var Fn=(t,e,n)=>(n=t!=null?ya(Na(t)):{},Sa(e||!t||!t.__esModule?zn(n,"default",{value:t,enumerable:!0}):n,t));var He=(t,e,n,i)=>{for(var r=i>1?void 0:i?Xi(e,n):e,o=t.length-1,s;o>=0;o--)(s=t[o])&&(r=(i?s(e,n,r):s(r))||r);return i&&r&&zn(e,n,r),r};var _r=W((Ut,Xn)=>{(function(e,n){typeof Ut=="object"&&typeof Xn=="object"?Xn.exports=n():typeof define=="function"&&define.amd?define([],n):typeof Ut=="object"?Ut.ClipboardJS=n():e.ClipboardJS=n()})(Ut,function(){return function(){var t={686:function(i,r,o){"use strict";o.d(r,{default:function(){return I}});var s=o(279),a=o.n(s),c=o(370),d=o.n(c),l=o(817),g=o.n(l);function p(y){try{return document.execCommand(y)}catch{return!1}}var f=function(_){var E=g()(_);return p("cut"),E},b=f;function w(y){var _=document.documentElement.getAttribute("dir")==="rtl",E=document.createElement("textarea");E.style.fontSize="12pt",E.style.border="0",E.style.padding="0",E.style.margin="0",E.style.position="absolute",E.style[_?"right":"left"]="-9999px";var k=window.pageYOffset||document.documentElement.scrollTop;return E.style.top="".concat(k,"px"),E.setAttribute("readonly",""),E.value=y,E}var A=function(_,E){var k=w(_);E.container.appendChild(k);var $=g()(k);return p("copy"),k.remove(),$},z=function(_){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body},k="";return typeof _=="string"?k=A(_,E):_ instanceof HTMLInputElement&&!["text","search","url","tel","password"].includes(_?.type)?k=A(_.value,E):(k=g()(_),p("copy")),k},Y=z;function C(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?C=function(E){return typeof E}:C=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},C(y)}var M=function(){var _=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},E=_.action,k=E===void 0?"copy":E,$=_.container,D=_.target,ee=_.text;if(k!=="copy"&&k!=="cut")throw new Error('Invalid "action" value, use either "copy" or "cut"');if(D!==void 0)if(D&&C(D)==="object"&&D.nodeType===1){if(k==="copy"&&D.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if(k==="cut"&&(D.hasAttribute("readonly")||D.hasAttribute("disabled")))throw new Error(`Invalid "target" attribute. You can't cut text from elements with "readonly" or "disabled" attributes`)}else throw new Error('Invalid "target" value, use a valid Element');if(ee)return Y(ee,{container:$});if(D)return k==="cut"?b(D):Y(D,{container:$})},Z=M;function G(y){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?G=function(E){return typeof E}:G=function(E){return E&&typeof Symbol=="function"&&E.constructor===Symbol&&E!==Symbol.prototype?"symbol":typeof E},G(y)}function B(y,_){if(!(y instanceof _))throw new TypeError("Cannot call a class as a function")}function ne(y,_){for(var E=0;E<_.length;E++){var k=_[E];k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(y,k.key,k)}}function v(y,_,E){return _&&ne(y.prototype,_),E&&ne(y,E),y}function le(y,_){if(typeof _!="function"&&_!==null)throw new TypeError("Super expression must either be null or a function");y.prototype=Object.create(_&&_.prototype,{constructor:{value:y,writable:!0,configurable:!0}}),_&&re(y,_)}function re(y,_){return re=Object.setPrototypeOf||function(k,$){return k.__proto__=$,k},re(y,_)}function ue(y){var _=oe();return function(){var k=he(y),$;if(_){var D=he(this).constructor;$=Reflect.construct(k,arguments,D)}else $=k.apply(this,arguments);return se(this,$)}}function se(y,_){return _&&(G(_)==="object"||typeof _=="function")?_:te(y)}function te(y){if(y===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return y}function oe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch{return!1}}function he(y){return he=Object.setPrototypeOf?Object.getPrototypeOf:function(E){return E.__proto__||Object.getPrototypeOf(E)},he(y)}function m(y,_){var E="data-clipboard-".concat(y);if(_.hasAttribute(E))return _.getAttribute(E)}var T=function(y){le(E,y);var _=ue(E);function E(k,$){var D;return B(this,E),D=_.call(this),D.resolveOptions($),D.listenClick(k),D}return v(E,[{key:"resolveOptions",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.action=typeof $.action=="function"?$.action:this.defaultAction,this.target=typeof $.target=="function"?$.target:this.defaultTarget,this.text=typeof $.text=="function"?$.text:this.defaultText,this.container=G($.container)==="object"?$.container:document.body}},{key:"listenClick",value:function($){var D=this;this.listener=d()($,"click",function(ee){return D.onClick(ee)})}},{key:"onClick",value:function($){var D=$.delegateTarget||$.currentTarget,ee=this.action(D)||"copy",Re=Z({action:ee,container:this.container,target:this.target(D),text:this.text(D)});this.emit(Re?"success":"error",{action:ee,text:Re,trigger:D,clearSelection:function(){D&&D.focus(),window.getSelection().removeAllRanges()}})}},{key:"defaultAction",value:function($){return m("action",$)}},{key:"defaultTarget",value:function($){var D=m("target",$);if(D)return document.querySelector(D)}},{key:"defaultText",value:function($){return m("text",$)}},{key:"destroy",value:function(){this.listener.destroy()}}],[{key:"copy",value:function($){var D=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{container:document.body};return Y($,D)}},{key:"cut",value:function($){return b($)}},{key:"isSupported",value:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:["copy","cut"],D=typeof $=="string"?[$]:$,ee=!!document.queryCommandSupported;return D.forEach(function(Re){ee=ee&&!!document.queryCommandSupported(Re)}),ee}}]),E}(a()),I=T},828:function(i){var r=9;if(typeof Element<"u"&&!Element.prototype.matches){var o=Element.prototype;o.matches=o.matchesSelector||o.mozMatchesSelector||o.msMatchesSelector||o.oMatchesSelector||o.webkitMatchesSelector}function s(a,c){for(;a&&a.nodeType!==r;){if(typeof a.matches=="function"&&a.matches(c))return a;a=a.parentNode}}i.exports=s},438:function(i,r,o){var s=o(828);function a(l,g,p,f,b){var w=d.apply(this,arguments);return l.addEventListener(p,w,b),{destroy:function(){l.removeEventListener(p,w,b)}}}function c(l,g,p,f,b){return typeof l.addEventListener=="function"?a.apply(null,arguments):typeof p=="function"?a.bind(null,document).apply(null,arguments):(typeof l=="string"&&(l=document.querySelectorAll(l)),Array.prototype.map.call(l,function(w){return a(w,g,p,f,b)}))}function d(l,g,p,f){return function(b){b.delegateTarget=s(b.target,g),b.delegateTarget&&f.call(l,b)}}i.exports=c},879:function(i,r){r.node=function(o){return o!==void 0&&o instanceof HTMLElement&&o.nodeType===1},r.nodeList=function(o){var s=Object.prototype.toString.call(o);return o!==void 0&&(s==="[object NodeList]"||s==="[object HTMLCollection]")&&"length"in o&&(o.length===0||r.node(o[0]))},r.string=function(o){return typeof o=="string"||o instanceof String},r.fn=function(o){var s=Object.prototype.toString.call(o);return s==="[object Function]"}},370:function(i,r,o){var s=o(879),a=o(438);function c(p,f,b){if(!p&&!f&&!b)throw new Error("Missing required arguments");if(!s.string(f))throw new TypeError("Second argument must be a String");if(!s.fn(b))throw new TypeError("Third argument must be a Function");if(s.node(p))return d(p,f,b);if(s.nodeList(p))return l(p,f,b);if(s.string(p))return g(p,f,b);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function d(p,f,b){return p.addEventListener(f,b),{destroy:function(){p.removeEventListener(f,b)}}}function l(p,f,b){return Array.prototype.forEach.call(p,function(w){w.addEventListener(f,b)}),{destroy:function(){Array.prototype.forEach.call(p,function(w){w.removeEventListener(f,b)})}}}function g(p,f,b){return a(document.body,p,f,b)}i.exports=c},817:function(i){function r(o){var s;if(o.nodeName==="SELECT")o.focus(),s=o.value;else if(o.nodeName==="INPUT"||o.nodeName==="TEXTAREA"){var a=o.hasAttribute("readonly");a||o.setAttribute("readonly",""),o.select(),o.setSelectionRange(0,o.value.length),a||o.removeAttribute("readonly"),s=o.value}else{o.hasAttribute("contenteditable")&&o.focus();var c=window.getSelection(),d=document.createRange();d.selectNodeContents(o),c.removeAllRanges(),c.addRange(d),s=c.toString()}return s}i.exports=r},279:function(i){function r(){}r.prototype={on:function(o,s,a){var c=this.e||(this.e={});return(c[o]||(c[o]=[])).push({fn:s,ctx:a}),this},once:function(o,s,a){var c=this;function d(){c.off(o,d),s.apply(a,arguments)}return d._=s,this.on(o,d,a)},emit:function(o){var s=[].slice.call(arguments,1),a=((this.e||(this.e={}))[o]||[]).slice(),c=0,d=a.length;for(c;c{function Ar(t){return t instanceof Map?t.clear=t.delete=t.set=function(){throw new Error("map is read-only")}:t instanceof Set&&(t.add=t.clear=t.delete=function(){throw new Error("set is read-only")}),Object.freeze(t),Object.getOwnPropertyNames(t).forEach(e=>{let n=t[e],i=typeof n;(i==="object"||i==="function")&&!Object.isFrozen(n)&&Ar(n)}),t}var ln=class{constructor(e){e.data===void 0&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function vr(t){return t.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function We(t,...e){let n=Object.create(null);for(let i in t)n[i]=t[i];return e.forEach(function(i){for(let r in i)n[r]=i[r]}),n}var za="",Er=t=>!!t.scope,Fa=(t,{prefix:e})=>{if(t.startsWith("language:"))return t.replace("language:","language-");if(t.includes(".")){let n=t.split(".");return[`${e}${n.shift()}`,...n.map((i,r)=>`${i}${"_".repeat(r+1)}`)].join(" ")}return`${e}${t}`},Jn=class{constructor(e,n){this.buffer="",this.classPrefix=n.classPrefix,e.walk(this)}addText(e){this.buffer+=vr(e)}openNode(e){if(!Er(e))return;let n=Fa(e.scope,{prefix:this.classPrefix});this.span(n)}closeNode(e){Er(e)&&(this.buffer+=za)}value(){return this.buffer}span(e){this.buffer+=``}},yr=(t={})=>{let e={children:[]};return Object.assign(e,t),e},jn=class t{constructor(){this.rootNode=yr(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){let n=yr({scope:e});this.add(n),this.stack.push(n)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,n){return typeof n=="string"?e.addText(n):n.children&&(e.openNode(n),n.children.forEach(i=>this._walk(e,i)),e.closeNode(n)),e}static _collapse(e){typeof e!="string"&&e.children&&(e.children.every(n=>typeof n=="string")?e.children=[e.children.join("")]:e.children.forEach(n=>{t._collapse(n)}))}},ei=class extends jn{constructor(e){super(),this.options=e}addText(e){e!==""&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,n){let i=e.root;n&&(i.scope=`language:${n}`),this.add(i)}toHTML(){return new Jn(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}};function Bt(t){return t?typeof t=="string"?t:t.source:null}function kr(t){return et("(?=",t,")")}function Ha(t){return et("(?:",t,")*")}function Ga(t){return et("(?:",t,")?")}function et(...t){return t.map(n=>Bt(n)).join("")}function Ka(t){let e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function ni(...t){return"("+(Ka(t).capture?"":"?:")+t.map(i=>Bt(i)).join("|")+")"}function xr(t){return new RegExp(t.toString()+"|").exec("").length-1}function qa(t,e){let n=t&&t.exec(e);return n&&n.index===0}var Wa=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function ii(t,{joinWith:e}){let n=0;return t.map(i=>{n+=1;let r=n,o=Bt(i),s="";for(;o.length>0;){let a=Wa.exec(o);if(!a){s+=o;break}s+=o.substring(0,a.index),o=o.substring(a.index+a[0].length),a[0][0]==="\\"&&a[1]?s+="\\"+String(Number(a[1])+r):(s+=a[0],a[0]==="("&&n++)}return s}).map(i=>`(${i})`).join(e)}var Za=/\b\B/,Or="[a-zA-Z]\\w*",ri="[a-zA-Z_]\\w*",Rr="\\b\\d+(\\.\\d+)?",Cr="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",Mr="\\b(0b[01]+)",Ya="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",Va=(t={})=>{let e=/^#![ ]*\//;return t.binary&&(t.begin=et(e,/.*\b/,t.binary,/\b.*/)),We({scope:"meta",begin:e,end:/$/,relevance:0,"on:begin":(n,i)=>{n.index!==0&&i.ignoreMatch()}},t)},zt={begin:"\\\\[\\s\\S]",relevance:0},Xa={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[zt]},Qa={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[zt]},Ja={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},dn=function(t,e,n={}){let i=We({scope:"comment",begin:t,end:e,contains:[]},n);i.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});let r=ni("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return i.contains.push({begin:et(/[ ]+/,"(",r,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),i},ja=dn("//","$"),ec=dn("/\\*","\\*/"),tc=dn("#","$"),nc={scope:"number",begin:Rr,relevance:0},ic={scope:"number",begin:Cr,relevance:0},rc={scope:"number",begin:Mr,relevance:0},sc={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[zt,{begin:/\[/,end:/\]/,relevance:0,contains:[zt]}]},oc={scope:"title",begin:Or,relevance:0},ac={scope:"title",begin:ri,relevance:0},cc={begin:"\\.\\s*"+ri,relevance:0},lc=function(t){return Object.assign(t,{"on:begin":(e,n)=>{n.data._beginMatch=e[1]},"on:end":(e,n)=>{n.data._beginMatch!==e[1]&&n.ignoreMatch()}})},cn=Object.freeze({__proto__:null,APOS_STRING_MODE:Xa,BACKSLASH_ESCAPE:zt,BINARY_NUMBER_MODE:rc,BINARY_NUMBER_RE:Mr,COMMENT:dn,C_BLOCK_COMMENT_MODE:ec,C_LINE_COMMENT_MODE:ja,C_NUMBER_MODE:ic,C_NUMBER_RE:Cr,END_SAME_AS_BEGIN:lc,HASH_COMMENT_MODE:tc,IDENT_RE:Or,MATCH_NOTHING_RE:Za,METHOD_GUARD:cc,NUMBER_MODE:nc,NUMBER_RE:Rr,PHRASAL_WORDS_MODE:Ja,QUOTE_STRING_MODE:Qa,REGEXP_MODE:sc,RE_STARTERS_RE:Ya,SHEBANG:Va,TITLE_MODE:oc,UNDERSCORE_IDENT_RE:ri,UNDERSCORE_TITLE_MODE:ac});function uc(t,e){t.input[t.index-1]==="."&&e.ignoreMatch()}function dc(t,e){t.className!==void 0&&(t.scope=t.className,delete t.className)}function pc(t,e){e&&t.beginKeywords&&(t.begin="\\b("+t.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",t.__beforeBegin=uc,t.keywords=t.keywords||t.beginKeywords,delete t.beginKeywords,t.relevance===void 0&&(t.relevance=0))}function gc(t,e){Array.isArray(t.illegal)&&(t.illegal=ni(...t.illegal))}function fc(t,e){if(t.match){if(t.begin||t.end)throw new Error("begin & end are not supported with match");t.begin=t.match,delete t.match}}function mc(t,e){t.relevance===void 0&&(t.relevance=1)}var hc=(t,e)=>{if(!t.beforeMatch)return;if(t.starts)throw new Error("beforeMatch cannot be used with starts");let n=Object.assign({},t);Object.keys(t).forEach(i=>{delete t[i]}),t.keywords=n.keywords,t.begin=et(n.beforeMatch,kr(n.begin)),t.starts={relevance:0,contains:[Object.assign(n,{endsParent:!0})]},t.relevance=0,delete n.beforeMatch},bc=["of","and","for","in","not","or","if","then","parent","list","value"],_c="keyword";function Ir(t,e,n=_c){let i=Object.create(null);return typeof t=="string"?r(n,t.split(" ")):Array.isArray(t)?r(n,t):Object.keys(t).forEach(function(o){Object.assign(i,Ir(t[o],e,o))}),i;function r(o,s){e&&(s=s.map(a=>a.toLowerCase())),s.forEach(function(a){let c=a.split("|");i[c[0]]=[o,Ec(c[0],c[1])]})}}function Ec(t,e){return e?Number(e):yc(t)?0:1}function yc(t){return bc.includes(t.toLowerCase())}var Tr={},je=t=>{console.error(t)},Nr=(t,...e)=>{console.log(`WARN: ${t}`,...e)},mt=(t,e)=>{Tr[`${t}/${e}`]||(console.log(`Deprecated as of ${t}. ${e}`),Tr[`${t}/${e}`]=!0)},un=new Error;function Lr(t,e,{key:n}){let i=0,r=t[n],o={},s={};for(let a=1;a<=e.length;a++)s[a+i]=r[a],o[a+i]=!0,i+=xr(e[a-1]);t[n]=s,t[n]._emit=o,t[n]._multi=!0}function Tc(t){if(Array.isArray(t.begin)){if(t.skip||t.excludeBegin||t.returnBegin)throw je("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),un;if(typeof t.beginScope!="object"||t.beginScope===null)throw je("beginScope must be object"),un;Lr(t,t.begin,{key:"beginScope"}),t.begin=ii(t.begin,{joinWith:""})}}function Nc(t){if(Array.isArray(t.end)){if(t.skip||t.excludeEnd||t.returnEnd)throw je("skip, excludeEnd, returnEnd not compatible with endScope: {}"),un;if(typeof t.endScope!="object"||t.endScope===null)throw je("endScope must be object"),un;Lr(t,t.end,{key:"endScope"}),t.end=ii(t.end,{joinWith:""})}}function wc(t){t.scope&&typeof t.scope=="object"&&t.scope!==null&&(t.beginScope=t.scope,delete t.scope)}function Sc(t){wc(t),typeof t.beginScope=="string"&&(t.beginScope={_wrap:t.beginScope}),typeof t.endScope=="string"&&(t.endScope={_wrap:t.endScope}),Tc(t),Nc(t)}function Ac(t){function e(s,a){return new RegExp(Bt(s),"m"+(t.case_insensitive?"i":"")+(t.unicodeRegex?"u":"")+(a?"g":""))}class n{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(a,c){c.position=this.position++,this.matchIndexes[this.matchAt]=c,this.regexes.push([c,a]),this.matchAt+=xr(a)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);let a=this.regexes.map(c=>c[1]);this.matcherRe=e(ii(a,{joinWith:"|"}),!0),this.lastIndex=0}exec(a){this.matcherRe.lastIndex=this.lastIndex;let c=this.matcherRe.exec(a);if(!c)return null;let d=c.findIndex((g,p)=>p>0&&g!==void 0),l=this.matchIndexes[d];return c.splice(0,d),Object.assign(c,l)}}class i{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(a){if(this.multiRegexes[a])return this.multiRegexes[a];let c=new n;return this.rules.slice(a).forEach(([d,l])=>c.addRule(d,l)),c.compile(),this.multiRegexes[a]=c,c}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(a,c){this.rules.push([a,c]),c.type==="begin"&&this.count++}exec(a){let c=this.getMatcher(this.regexIndex);c.lastIndex=this.lastIndex;let d=c.exec(a);if(this.resumingScanAtSamePosition()&&!(d&&d.index===this.lastIndex)){let l=this.getMatcher(0);l.lastIndex=this.lastIndex+1,d=l.exec(a)}return d&&(this.regexIndex+=d.position+1,this.regexIndex===this.count&&this.considerAll()),d}}function r(s){let a=new i;return s.contains.forEach(c=>a.addRule(c.begin,{rule:c,type:"begin"})),s.terminatorEnd&&a.addRule(s.terminatorEnd,{type:"end"}),s.illegal&&a.addRule(s.illegal,{type:"illegal"}),a}function o(s,a){let c=s;if(s.isCompiled)return c;[dc,fc,Sc,hc].forEach(l=>l(s,a)),t.compilerExtensions.forEach(l=>l(s,a)),s.__beforeBegin=null,[pc,gc,mc].forEach(l=>l(s,a)),s.isCompiled=!0;let d=null;return typeof s.keywords=="object"&&s.keywords.$pattern&&(s.keywords=Object.assign({},s.keywords),d=s.keywords.$pattern,delete s.keywords.$pattern),d=d||/\w+/,s.keywords&&(s.keywords=Ir(s.keywords,t.case_insensitive)),c.keywordPatternRe=e(d,!0),a&&(s.begin||(s.begin=/\B|\b/),c.beginRe=e(c.begin),!s.end&&!s.endsWithParent&&(s.end=/\B|\b/),s.end&&(c.endRe=e(c.end)),c.terminatorEnd=Bt(c.end)||"",s.endsWithParent&&a.terminatorEnd&&(c.terminatorEnd+=(s.end?"|":"")+a.terminatorEnd)),s.illegal&&(c.illegalRe=e(s.illegal)),s.contains||(s.contains=[]),s.contains=[].concat(...s.contains.map(function(l){return vc(l==="self"?s:l)})),s.contains.forEach(function(l){o(l,c)}),s.starts&&o(s.starts,a),c.matcher=r(c),c}if(t.compilerExtensions||(t.compilerExtensions=[]),t.contains&&t.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return t.classNameAliases=We(t.classNameAliases||{}),o(t)}function Dr(t){return t?t.endsWithParent||Dr(t.starts):!1}function vc(t){return t.variants&&!t.cachedVariants&&(t.cachedVariants=t.variants.map(function(e){return We(t,{variants:null},e)})),t.cachedVariants?t.cachedVariants:Dr(t)?We(t,{starts:t.starts?We(t.starts):null}):Object.isFrozen(t)?We(t):t}var kc="11.9.0",ti=class extends Error{constructor(e,n){super(e),this.name="HTMLInjectionError",this.html=n}},Qn=vr,wr=We,Sr=Symbol("nomatch"),xc=7,$r=function(t){let e=Object.create(null),n=Object.create(null),i=[],r=!0,o="Could not find the language '{}', did you forget to load/include a language module?",s={disableAutodetect:!0,name:"Plain text",contains:[]},a={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:ei};function c(m){return a.noHighlightRe.test(m)}function d(m){let T=m.className+" ";T+=m.parentNode?m.parentNode.className:"";let I=a.languageDetectRe.exec(T);if(I){let y=v(I[1]);return y||(Nr(o.replace("{}",I[1])),Nr("Falling back to no-highlight mode for this block.",m)),y?I[1]:"no-highlight"}return T.split(/\s+/).find(y=>c(y)||v(y))}function l(m,T,I){let y="",_="";typeof T=="object"?(y=m,I=T.ignoreIllegals,_=T.language):(mt("10.7.0","highlight(lang, code, ...args) has been deprecated."),mt("10.7.0",`Please use highlight(code, options) instead.
-https://github.com/highlightjs/highlight.js/issues/2277`),_=m,y=T),I===void 0&&(I=!0);let E={code:y,language:_};oe("before:highlight",E);let k=E.result?E.result:g(E.language,E.code,I);return k.code=E.code,oe("after:highlight",k),k}function g(m,T,I,y){let _=Object.create(null);function E(N,O){return N.keywords[O]}function k(){if(!P.keywords){S.addText(R);return}let N=0;P.keywordPatternRe.lastIndex=0;let O=P.keywordPatternRe.exec(R),U="";for(;O;){U+=R.substring(N,O.index);let V=Te.case_insensitive?O[0].toLowerCase():O[0],de=E(P,V);if(de){let[Ce,st]=de;if(S.addText(U),U="",_[V]=(_[V]||0)+1,_[V]<=xc&&(q+=st),Ce.startsWith("_"))U+=O[0];else{let ot=Te.classNameAliases[Ce]||Ce;ee(O[0],ot)}}else U+=O[0];N=P.keywordPatternRe.lastIndex,O=P.keywordPatternRe.exec(R)}U+=R.substring(N),S.addText(U)}function $(){if(R==="")return;let N=null;if(typeof P.subLanguage=="string"){if(!e[P.subLanguage]){S.addText(R);return}N=g(P.subLanguage,R,!0,K[P.subLanguage]),K[P.subLanguage]=N._top}else N=f(R,P.subLanguage.length?P.subLanguage:null);P.relevance>0&&(q+=N.relevance),S.__addSublanguage(N._emitter,N.language)}function D(){P.subLanguage!=null?$():k(),R=""}function ee(N,O){N!==""&&(S.startScope(O),S.addText(N),S.endScope())}function Re(N,O){let U=1,V=O.length-1;for(;U<=V;){if(!N._emit[U]){U++;continue}let de=Te.classNameAliases[N[U]]||N[U],Ce=O[U];de?ee(Ce,de):(R=Ce,k(),R=""),U++}}function Fe(N,O){return N.scope&&typeof N.scope=="string"&&S.openNode(Te.classNameAliases[N.scope]||N.scope),N.beginScope&&(N.beginScope._wrap?(ee(R,Te.classNameAliases[N.beginScope._wrap]||N.beginScope._wrap),R=""):N.beginScope._multi&&(Re(N.beginScope,O),R="")),P=Object.create(N,{parent:{value:P}}),P}function Ye(N,O,U){let V=qa(N.endRe,U);if(V){if(N["on:end"]){let de=new ln(N);N["on:end"](O,de),de.isMatchIgnored&&(V=!1)}if(V){for(;N.endsParent&&N.parent;)N=N.parent;return N}}if(N.endsWithParent)return Ye(N.parent,O,U)}function Nt(N){return P.matcher.regexIndex===0?(R+=N[0],1):(Me=!0,0)}function wt(N){let O=N[0],U=N.rule,V=new ln(U),de=[U.__beforeBegin,U["on:begin"]];for(let Ce of de)if(Ce&&(Ce(N,V),V.isMatchIgnored))return Nt(O);return U.skip?R+=O:(U.excludeBegin&&(R+=O),D(),!U.returnBegin&&!U.excludeBegin&&(R=O)),Fe(U,N),U.returnBegin?0:O.length}function it(N){let O=N[0],U=T.substring(N.index),V=Ye(P,N,U);if(!V)return Sr;let de=P;P.endScope&&P.endScope._wrap?(D(),ee(O,P.endScope._wrap)):P.endScope&&P.endScope._multi?(D(),Re(P.endScope,N)):de.skip?R+=O:(de.returnEnd||de.excludeEnd||(R+=O),D(),de.excludeEnd&&(R=O));do P.scope&&S.closeNode(),!P.skip&&!P.subLanguage&&(q+=P.relevance),P=P.parent;while(P!==V.parent);return V.starts&&Fe(V.starts,N),de.returnEnd?0:O.length}function X(){let N=[];for(let O=P;O!==Te;O=O.parent)O.scope&&N.unshift(O.scope);N.forEach(O=>S.openNode(O))}let ke={};function be(N,O){let U=O&&O[0];if(R+=N,U==null)return D(),0;if(ke.type==="begin"&&O.type==="end"&&ke.index===O.index&&U===""){if(R+=T.slice(O.index,O.index+1),!r){let V=new Error(`0 width match regex (${m})`);throw V.languageName=m,V.badRule=ke.rule,V}return 1}if(ke=O,O.type==="begin")return wt(O);if(O.type==="illegal"&&!I){let V=new Error('Illegal lexeme "'+U+'" for mode "'+(P.scope||"")+'"');throw V.mode=P,V}else if(O.type==="end"){let V=it(O);if(V!==Sr)return V}if(O.type==="illegal"&&U==="")return 1;if(Ae>1e5&&Ae>O.index*3)throw new Error("potential infinite loop, way more iterations than matches");return R+=U,U.length}let Te=v(m);if(!Te)throw je(o.replace("{}",m)),new Error('Unknown language: "'+m+'"');let An=Ac(Te),rt="",P=y||An,K={},S=new a.__emitter(a);X();let R="",q=0,ie=0,Ae=0,Me=!1;try{if(Te.__emitTokens)Te.__emitTokens(T,S);else{for(P.matcher.considerAll();;){Ae++,Me?Me=!1:P.matcher.considerAll(),P.matcher.lastIndex=ie;let N=P.matcher.exec(T);if(!N)break;let O=T.substring(ie,N.index),U=be(O,N);ie=N.index+U}be(T.substring(ie))}return S.finalize(),rt=S.toHTML(),{language:m,value:rt,relevance:q,illegal:!1,_emitter:S,_top:P}}catch(N){if(N.message&&N.message.includes("Illegal"))return{language:m,value:Qn(T),illegal:!0,relevance:0,_illegalBy:{message:N.message,index:ie,context:T.slice(ie-100,ie+100),mode:N.mode,resultSoFar:rt},_emitter:S};if(r)return{language:m,value:Qn(T),illegal:!1,relevance:0,errorRaised:N,_emitter:S,_top:P};throw N}}function p(m){let T={value:Qn(m),illegal:!1,relevance:0,_top:s,_emitter:new a.__emitter(a)};return T._emitter.addText(m),T}function f(m,T){T=T||a.languages||Object.keys(e);let I=p(m),y=T.filter(v).filter(re).map(D=>g(D,m,!1));y.unshift(I);let _=y.sort((D,ee)=>{if(D.relevance!==ee.relevance)return ee.relevance-D.relevance;if(D.language&&ee.language){if(v(D.language).supersetOf===ee.language)return 1;if(v(ee.language).supersetOf===D.language)return-1}return 0}),[E,k]=_,$=E;return $.secondBest=k,$}function b(m,T,I){let y=T&&n[T]||I;m.classList.add("hljs"),m.classList.add(`language-${y}`)}function w(m){let T=null,I=d(m);if(c(I))return;if(oe("before:highlightElement",{el:m,language:I}),m.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",m);return}if(m.children.length>0&&(a.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(m)),a.throwUnescapedHTML))throw new ti("One of your code blocks includes unescaped HTML.",m.innerHTML);T=m;let y=T.textContent,_=I?l(y,{language:I,ignoreIllegals:!0}):f(y);m.innerHTML=_.value,m.dataset.highlighted="yes",b(m,I,_.language),m.result={language:_.language,re:_.relevance,relevance:_.relevance},_.secondBest&&(m.secondBest={language:_.secondBest.language,relevance:_.secondBest.relevance}),oe("after:highlightElement",{el:m,result:_,text:y})}function A(m){a=wr(a,m)}let z=()=>{M(),mt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Y(){M(),mt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let C=!1;function M(){if(document.readyState==="loading"){C=!0;return}document.querySelectorAll(a.cssSelector).forEach(w)}function Z(){C&&M()}typeof window<"u"&&window.addEventListener&&window.addEventListener("DOMContentLoaded",Z,!1);function G(m,T){let I=null;try{I=T(t)}catch(y){if(je("Language definition for '{}' could not be registered.".replace("{}",m)),r)je(y);else throw y;I=s}I.name||(I.name=m),e[m]=I,I.rawDefinition=T.bind(null,t),I.aliases&&le(I.aliases,{languageName:m})}function B(m){delete e[m];for(let T of Object.keys(n))n[T]===m&&delete n[T]}function ne(){return Object.keys(e)}function v(m){return m=(m||"").toLowerCase(),e[m]||e[n[m]]}function le(m,{languageName:T}){typeof m=="string"&&(m=[m]),m.forEach(I=>{n[I.toLowerCase()]=T})}function re(m){let T=v(m);return T&&!T.disableAutodetect}function ue(m){m["before:highlightBlock"]&&!m["before:highlightElement"]&&(m["before:highlightElement"]=T=>{m["before:highlightBlock"](Object.assign({block:T.el},T))}),m["after:highlightBlock"]&&!m["after:highlightElement"]&&(m["after:highlightElement"]=T=>{m["after:highlightBlock"](Object.assign({block:T.el},T))})}function se(m){ue(m),i.push(m)}function te(m){let T=i.indexOf(m);T!==-1&&i.splice(T,1)}function oe(m,T){let I=m;i.forEach(function(y){y[I]&&y[I](T)})}function he(m){return mt("10.7.0","highlightBlock will be removed entirely in v12.0"),mt("10.7.0","Please use highlightElement now."),w(m)}Object.assign(t,{highlight:l,highlightAuto:f,highlightAll:M,highlightElement:w,highlightBlock:he,configure:A,initHighlighting:z,initHighlightingOnLoad:Y,registerLanguage:G,unregisterLanguage:B,listLanguages:ne,getLanguage:v,registerAliases:le,autoDetection:re,inherit:wr,addPlugin:se,removePlugin:te}),t.debugMode=function(){r=!1},t.safeMode=function(){r=!0},t.versionString=kc,t.regex={concat:et,lookahead:kr,either:ni,optional:Ga,anyNumberOfTimes:Ha};for(let m in cn)typeof cn[m]=="object"&&Ar(cn[m]);return Object.assign(t,cn),t},ht=$r({});ht.newInstance=()=>$r({});Pr.exports=ht;ht.HighlightJS=ht;ht.default=ht});var zr=W((wd,Br)=>{function Oc(t){let e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),i=/[\p{L}0-9._:-]+/u,r={className:"symbol",begin:/&[a-z]+;|[0-9]+;|[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},s=t.inherit(o,{begin:/\(/,end:/\)/}),a=t.inherit(t.APOS_STRING_MODE,{className:"string"}),c=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),d={endsWithParent:!0,illegal:/,relevance:0,contains:[{className:"attr",begin:i,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[r]},{begin:/'/,end:/'/,contains:[r]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin://,relevance:10,contains:[o,c,a,s,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin://,contains:[o,s,c,a]}]}]},t.COMMENT(//,{relevance:10}),{begin://,relevance:10},r,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[c]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/