@emberkit/core 0.2.6-alpha.0 → 0.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoBtE,wBAAgB,kBAAkB,CAAC,WAAW,GAAE,qBAA0B,GAAG,MAAM,CA8FlF;AAk3BD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AACnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAoBtE,wBAAgB,kBAAkB,CAAC,WAAW,GAAE,qBAA0B,GAAG,MAAM,CA8FlF;AA8kCD,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC"}
@@ -330,6 +330,15 @@ function renderCodeBlock(lang, code) {
330
330
  else if (lang === 'json') {
331
331
  highlighted = highlightJSON(highlighted);
332
332
  }
333
+ else if (lang === 'html' || lang === 'xml' || lang === 'svg') {
334
+ highlighted = highlightHTML(highlighted);
335
+ }
336
+ else if (lang === 'css' || lang === 'scss' || lang === 'sass' || lang === 'less') {
337
+ highlighted = highlightCSS(highlighted);
338
+ }
339
+ else if (lang === 'markdown' || lang === 'md') {
340
+ highlighted = highlightMarkdown(highlighted);
341
+ }
333
342
  else {
334
343
  highlighted = escapeHtml(highlighted);
335
344
  }
@@ -728,6 +737,193 @@ function highlightJSON(code) {
728
737
  result = result.replace(/:\s*(true|false|null)/g, ': <span class="kw">$1</span>');
729
738
  return result;
730
739
  }
740
+ function highlightHTML(code) {
741
+ const tokens = [];
742
+ let remaining = code;
743
+ while (remaining.length > 0) {
744
+ let m;
745
+ // HTML comment
746
+ m = remaining.match(/^<!--[\s\S]*?-->/);
747
+ if (m) {
748
+ tokens.push(`<span class="cm">${escapeHtml(m[0])}</span>`);
749
+ remaining = remaining.slice(m[0].length);
750
+ continue;
751
+ }
752
+ // DOCTYPE
753
+ m = remaining.match(/^<!DOCTYPE[^>]*>/i);
754
+ if (m) {
755
+ tokens.push(`<span class="kw">${escapeHtml(m[0])}</span>`);
756
+ remaining = remaining.slice(m[0].length);
757
+ continue;
758
+ }
759
+ // Closing tag </tag>
760
+ m = remaining.match(/^(<\/)([a-zA-Z][\w-]*)(>)/);
761
+ if (m) {
762
+ tokens.push(`<span class="op">&lt;/</span><span class="tag">${m[2]}</span><span class="op">&gt;</span>`);
763
+ remaining = remaining.slice(m[0].length);
764
+ continue;
765
+ }
766
+ // Opening tag start <tag — capture tag name, then walk attrs until >
767
+ m = remaining.match(/^(<)([a-zA-Z][\w-]*)/);
768
+ if (m) {
769
+ tokens.push(`<span class="op">&lt;</span><span class="tag">${m[2]}</span>`);
770
+ remaining = remaining.slice(m[0].length);
771
+ // Walk attributes until we hit > or />
772
+ while (remaining.length > 0) {
773
+ // Self-close />
774
+ let am = remaining.match(/^(\s*\/>)/);
775
+ if (am) {
776
+ tokens.push(`<span class="op">${escapeHtml(am[1])}</span>`);
777
+ remaining = remaining.slice(am[1].length);
778
+ break;
779
+ }
780
+ // Close >
781
+ am = remaining.match(/^(\s*>)/);
782
+ if (am) {
783
+ tokens.push(`<span class="op">${escapeHtml(am[1])}</span>`);
784
+ remaining = remaining.slice(am[1].length);
785
+ break;
786
+ }
787
+ // Attribute with quoted value
788
+ am = remaining.match(/^(\s+)([a-zA-Z_:][\w:.-]*)(\s*=\s*)("[^"]*"|'[^']*')/);
789
+ if (am) {
790
+ tokens.push(`${am[1]}<span class="attr">${am[2]}</span><span class="op">${escapeHtml(am[3])}</span><span class="str">${escapeHtml(am[4])}</span>`);
791
+ remaining = remaining.slice(am[0].length);
792
+ continue;
793
+ }
794
+ // Boolean attribute
795
+ am = remaining.match(/^(\s+)([a-zA-Z_:][\w:.-]*)/);
796
+ if (am) {
797
+ tokens.push(`${am[1]}<span class="attr">${am[2]}</span>`);
798
+ remaining = remaining.slice(am[0].length);
799
+ continue;
800
+ }
801
+ // Anything else (whitespace, = alone, etc.)
802
+ tokens.push(escapeHtml(remaining[0]));
803
+ remaining = remaining.slice(1);
804
+ }
805
+ continue;
806
+ }
807
+ // Text content — consume until next < or end
808
+ m = remaining.match(/^[^<]+/);
809
+ if (m) {
810
+ tokens.push(escapeHtml(m[0]));
811
+ remaining = remaining.slice(m[0].length);
812
+ continue;
813
+ }
814
+ tokens.push(escapeHtml(remaining[0]));
815
+ remaining = remaining.slice(1);
816
+ }
817
+ return tokens.join('');
818
+ }
819
+ function highlightCSS(code) {
820
+ const tokens = [];
821
+ let remaining = code;
822
+ while (remaining.length > 0) {
823
+ let m;
824
+ // Block comment
825
+ m = remaining.match(/^\/\*[\s\S]*?\*\//);
826
+ if (m) {
827
+ tokens.push(`<span class="cm">${escapeHtml(m[0])}</span>`);
828
+ remaining = remaining.slice(m[0].length);
829
+ continue;
830
+ }
831
+ // String
832
+ m = remaining.match(/^('[^']*'|"[^"]*")/);
833
+ if (m) {
834
+ tokens.push(`<span class="str">${escapeHtml(m[0])}</span>`);
835
+ remaining = remaining.slice(m[0].length);
836
+ continue;
837
+ }
838
+ // At-rule (@import, @media, etc.)
839
+ m = remaining.match(/^(@[\w-]+)/);
840
+ if (m) {
841
+ tokens.push(`<span class="kw">${m[0]}</span>`);
842
+ remaining = remaining.slice(m[0].length);
843
+ continue;
844
+ }
845
+ // Hex color
846
+ m = remaining.match(/^(#[0-9a-fA-F]{3,8})\b/);
847
+ if (m) {
848
+ tokens.push(`<span class="num">${m[0]}</span>`);
849
+ remaining = remaining.slice(m[0].length);
850
+ continue;
851
+ }
852
+ // Number with optional unit
853
+ m = remaining.match(/^(\d+\.?\d*(?:px|em|rem|vh|vw|%|s|ms|deg|fr)?)/);
854
+ if (m) {
855
+ tokens.push(`<span class="num">${m[0]}</span>`);
856
+ remaining = remaining.slice(m[0].length);
857
+ continue;
858
+ }
859
+ // Property name (word before colon)
860
+ m = remaining.match(/^([\w-]+)(\s*:)/);
861
+ if (m) {
862
+ tokens.push(`<span class="attr">${m[1]}</span><span class="op">${m[2]}</span>`);
863
+ remaining = remaining.slice(m[0].length);
864
+ continue;
865
+ }
866
+ // CSS value keywords
867
+ m = remaining.match(/^(none|auto|inherit|initial|unset|revert|flex|grid|block|inline|absolute|relative|fixed|sticky|center|left|right|top|bottom|normal|bold|italic)\b/);
868
+ if (m) {
869
+ tokens.push(`<span class="val">${m[0]}</span>`);
870
+ remaining = remaining.slice(m[0].length);
871
+ continue;
872
+ }
873
+ // Selector pseudo-class / pseudo-element
874
+ m = remaining.match(/^(:{1,2}[\w-]+)/);
875
+ if (m) {
876
+ tokens.push(`<span class="fn">${m[0]}</span>`);
877
+ remaining = remaining.slice(m[0].length);
878
+ continue;
879
+ }
880
+ // Selector class / id
881
+ m = remaining.match(/^([.#][\w-]+)/);
882
+ if (m) {
883
+ tokens.push(`<span class="type">${m[0]}</span>`);
884
+ remaining = remaining.slice(m[0].length);
885
+ continue;
886
+ }
887
+ m = remaining.match(/^(\s+)/);
888
+ if (m) {
889
+ tokens.push(m[0]);
890
+ remaining = remaining.slice(m[0].length);
891
+ continue;
892
+ }
893
+ tokens.push(escapeHtml(remaining[0]));
894
+ remaining = remaining.slice(1);
895
+ }
896
+ return tokens.join('');
897
+ }
898
+ function highlightMarkdown(code) {
899
+ return code
900
+ .split('\n')
901
+ .map((line) => {
902
+ const escaped = escapeHtml(line);
903
+ // Frontmatter delimiter
904
+ if (/^---$/.test(line))
905
+ return `<span class="op">${escaped}</span>`;
906
+ // Headings
907
+ const headingM = line.match(/^(#{1,6})\s(.+)/);
908
+ if (headingM) {
909
+ return `<span class="kw">${escapeHtml(headingM[1])}</span> <span class="tag">${escapeHtml(headingM[2])}</span>`;
910
+ }
911
+ // Bold / italic markers (keep simple — just colour the line)
912
+ if (/^\s*[-*+]\s/.test(line)) {
913
+ return `<span class="op">${escapeHtml(line.match(/^(\s*[-*+])/)[1])}</span>${escapeHtml(line.slice(line.match(/^(\s*[-*+])/)[1].length))}`;
914
+ }
915
+ // Blockquote
916
+ if (/^>/.test(line))
917
+ return `<span class="cm">${escaped}</span>`;
918
+ // Frontmatter key: value
919
+ const fmM = line.match(/^([\w-]+):\s*(.*)/);
920
+ if (fmM) {
921
+ return `<span class="attr">${escapeHtml(fmM[1])}</span><span class="op">:</span> <span class="str">${escapeHtml(fmM[2])}</span>`;
922
+ }
923
+ return escaped;
924
+ })
925
+ .join('\n');
926
+ }
731
927
  function processTables(html) {
732
928
  const lines = html.split('\n');
733
929
  const result = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emberkit/core",
3
- "version": "0.2.6-alpha.0",
3
+ "version": "0.2.7",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Lightweight TypeScript-first JSX framework core",