Skip to content
Repos

DevPlaceApp

C++ 2.9 KB58 lines Opens in site

Directory Raw Download

#pragma once
// Spec: SPEC.md UX-MD-01. Markdown parser caps and the DevPlace MarkdownUI theme values
// (DevPlaceIOS UI/Style/MarkdownTheme.swift plus the MarkdownUI default theme).
// VERIFIED values come from MarkdownTheme.swift. Values marked UNVERIFIED are reproduced from memory of
// MarkdownUI's Theme.basic and were not measured against a running iOS build.
#include <cstddef>

namespace dp::spec {

struct MarkdownLimits {
  static constexpr std::size_t kMaxInputChars = 200000;  // longer input is cut, the document is flagged truncated
  static constexpr int kMaxBlockNesting = 8;             // quotes and list items; deeper content becomes plain text
  static constexpr int kMaxInlineNesting = 12;           // emphasis and link depth
  static constexpr int kMaxBlocks = 5000;                // nodes in the AST, extra blocks are dropped
  static constexpr int kMaxDelimiters = 2000;            // emphasis and bracket candidates per inline run
  static constexpr int kMaxTableColumns = 32;
  static constexpr int kMaxTableRows = 500;
  static constexpr std::size_t kMaxUrlChars = 2048;
  static constexpr std::size_t kAstCacheEntries = 16;
};

struct MarkdownTheme {
  // ---- VERIFIED (MarkdownTheme.swift) ----
  static constexpr float kCodeFontEm = 0.85f;           // inline code and code blocks
  static constexpr float kQuoteBarEm = 0.2f;            // bar width
  static constexpr float kQuoteBarRadius = 6;
  static constexpr float kQuotePaddingEm = 1.0f;        // horizontal padding of the quote text
  static constexpr float kCodeBlockLineSpacingEm = 0.225f;
  static constexpr float kCodeBlockPadV = 6;
  static constexpr float kCodeBlockPadH = 10;
  static constexpr float kCodeBlockRadius = 8;
  static constexpr float kCodeBlockMarginTop = 6;
  static constexpr float kCodeBlockMarginBottom = 16;

  // ---- UNVERIFIED (MarkdownUI default theme) ----
  static constexpr float kHeadingEm[6] = {2.0f, 1.5f, 1.25f, 1.0f, 0.875f, 0.85f};
  static constexpr float kHeadingLineSpacingEm = 0.125f;
  static constexpr float kHeadingMarginTop = 24;
  static constexpr float kHeadingMarginBottom = 16;
  static constexpr float kParagraphLineSpacingEm = 0.25f;
  static constexpr float kBlockMarginBottom = 16;        // paragraph, list, quote, table
  static constexpr float kListItemMarginTopEm = 0.25f;
  static constexpr float kListMarkerMinWidthEm = 1.5f;
  static constexpr float kListMarkerGapEm = 0.25f;
  static constexpr float kTaskBoxEm = 0.9f;
  static constexpr float kRuleHeightEm = 0.25f;
  static constexpr float kRuleMargin = 24;
  static constexpr float kRuleOpacity = 0.35f;
  static constexpr float kTableCellPadV = 6;
  static constexpr float kTableCellPadH = 13;
  static constexpr float kTableBorderWidth = 1;
  static constexpr float kTableMaxCellWidth = 320;
  static constexpr float kImagePlaceholderHeight = 120;
  static constexpr float kImagePlaceholderRadius = 8;
  static constexpr int kImageRasterPx = 1024;
};

}  // namespace dp::spec
39.4ms