docula 1.10.0 → 1.10.1

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.
package/dist/docula.js CHANGED
@@ -1307,7 +1307,10 @@ import path5 from "path";
1307
1307
  import { Writr as Writr4 } from "writr";
1308
1308
  var writrOptions4 = {
1309
1309
  throwOnEmitError: false,
1310
- throwOnEmptyListeners: false
1310
+ throwOnEmptyListeners: false,
1311
+ renderOptions: {
1312
+ rawHtml: true
1313
+ }
1311
1314
  };
1312
1315
  function getChangelogEntries(changelogPath, options, hash, cachedEntries, previousHashes, currentHashes) {
1313
1316
  const entries = [];
@@ -1407,7 +1410,53 @@ function generateChangelogPreview(markdown, maxLength = 500, mdx = false) {
1407
1410
  if (cleaned.length <= minLength) {
1408
1411
  return new Writr4(cleaned, writrOptions4).renderSync({ mdx });
1409
1412
  }
1410
- const searchArea = cleaned.slice(0, maxLength);
1413
+ const htmlBlocks = [];
1414
+ const tagPattern = /<\/?(\w+)\b[^>]*>/g;
1415
+ const blockStarts = [];
1416
+ for (const tagMatch of cleaned.matchAll(tagPattern)) {
1417
+ const fullMatch = tagMatch[0];
1418
+ const tagName = tagMatch[1];
1419
+ const isClosing = fullMatch.startsWith("</");
1420
+ if (isClosing) {
1421
+ for (let i = blockStarts.length - 1; i >= 0; i--) {
1422
+ if (blockStarts[i].tag === tagName) {
1423
+ if (blockStarts[i].depth === 0) {
1424
+ htmlBlocks.push({
1425
+ start: blockStarts[i].index,
1426
+ end: tagMatch.index + fullMatch.length
1427
+ });
1428
+ blockStarts.splice(i, 1);
1429
+ } else {
1430
+ blockStarts[i].depth--;
1431
+ }
1432
+ break;
1433
+ }
1434
+ }
1435
+ } else if (!fullMatch.endsWith("/>")) {
1436
+ const existing = blockStarts.find((s) => s.tag === tagName);
1437
+ if (existing) {
1438
+ existing.depth++;
1439
+ } else {
1440
+ blockStarts.push({ tag: tagName, index: tagMatch.index, depth: 0 });
1441
+ }
1442
+ }
1443
+ }
1444
+ let effectiveMax = maxLength;
1445
+ let extended = true;
1446
+ while (extended) {
1447
+ extended = false;
1448
+ for (const block of htmlBlocks) {
1449
+ if (effectiveMax > block.start && effectiveMax < block.end) {
1450
+ let end = block.end;
1451
+ while (end < cleaned.length && cleaned[end] === "\n") {
1452
+ end++;
1453
+ }
1454
+ effectiveMax = end;
1455
+ extended = true;
1456
+ }
1457
+ }
1458
+ }
1459
+ const searchArea = cleaned.slice(0, effectiveMax);
1411
1460
  let splitIndex = -1;
1412
1461
  let pos = searchArea.lastIndexOf("\n\n");
1413
1462
  while (pos >= 0) {
@@ -1434,7 +1483,7 @@ function generateChangelogPreview(markdown, maxLength = 500, mdx = false) {
1434
1483
  let lastItemEnd = -1;
1435
1484
  for (const line of lines) {
1436
1485
  const lineEnd = charCount + line.length;
1437
- if (lineEnd <= maxLength && (/^[-*]\s/.test(line) || /^\d+\.\s/.test(line))) {
1486
+ if (lineEnd <= effectiveMax && (/^[-*]\s/.test(line) || /^\d+\.\s/.test(line))) {
1438
1487
  if (charCount > 0 && charCount >= minLength) {
1439
1488
  lastItemEnd = charCount - 1;
1440
1489
  }
@@ -1450,7 +1499,7 @@ function generateChangelogPreview(markdown, maxLength = 500, mdx = false) {
1450
1499
  const truncated2 = cleaned.slice(0, splitIndex).trim();
1451
1500
  return new Writr4(truncated2, writrOptions4).renderSync({ mdx });
1452
1501
  }
1453
- let truncated = cleaned.slice(0, maxLength);
1502
+ let truncated = cleaned.slice(0, effectiveMax);
1454
1503
  const lastSpace = truncated.lastIndexOf(" ");
1455
1504
  if (lastSpace > 0) {
1456
1505
  truncated = truncated.slice(0, lastSpace);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docula",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Beautiful Website for Your Projects",
5
5
  "type": "module",
6
6
  "main": "./dist/docula.js",
@@ -810,6 +810,11 @@ pre:hover .copy-code-btn { opacity: 1; }
810
810
  color: var(--muted);
811
811
  }
812
812
 
813
+ .changelog-entry-preview img {
814
+ max-width: 100%;
815
+ border-radius: 6px;
816
+ }
817
+
813
818
  .changelog-read-more {
814
819
  display: inline-block;
815
820
  margin-top: 8px;
@@ -134,6 +134,7 @@
134
134
  function setAuthUI(loggedIn, displayName) {
135
135
  window.__doculaAuth = { loggedIn: loggedIn, displayName: displayName };
136
136
  try { localStorage.setItem('docula-auth-state', JSON.stringify(window.__doculaAuth)); } catch(e) {}
137
+ document.documentElement.classList.toggle('docula-auth-logged-in', loggedIn);
137
138
  document.dispatchEvent(new CustomEvent('docula-auth-change'));
138
139
  var els = [
139
140
  { login: document.getElementById('cookie-auth-login'), logout: document.getElementById('cookie-auth-logout'), user: document.getElementById('cookie-auth-user') },