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

GitHub Flavored Markdown and native SwiftUI rendering #152

Merged
merged 35 commits into from Jan 22, 2023

Conversation

gonzalezreal
Copy link
Owner

@gonzalezreal gonzalezreal commented Oct 29, 2022

About

This pull request contains a rewrite of the library that brings the following features:

  • GitHub Flavored Markdown (autolinks, strikethrough text, task lists, and tables)
  • Native SwiftUI rendering
  • Themes and full customization of inlines and blocks

Breaking changes

  • MarkdownUI now requires macOS 12+, iOS 15+, tvOS 15+ and watchOS 8+
  • MarkdownUI now uses SwiftUI primitives to render Markdown and no longer depends on gonzalezreal/AttributedText.
  • MarkdownUI brings a new DSL to create Markdown content and no longer depends on gonzalezreal/SwiftCommonMark.
  • MarkdownStyle and all of its subtypes are no longer available. Use the new Theme API to customize the Markdown appearance.
  • MarkdownImageHandler is no longer available. Use the new ImageProvider API to customize the image loading behavior.

Status

Markdown rendering and styling:

  • Inline text
  • Images
  • Paragraphs
  • Blockquotes
  • Task lists
  • Lists
  • Code blocks
  • Tables
  • Headings
  • Thematic breaks

Other stuff:

  • Theme support
  • DocC theme
  • GitHub theme
  • Sample code
  • watchOS support
  • Heading anchors
  • API to integrate a code syntax highlighter
  • API to integrate other image loading systems
  • Documentation

gonzalezreal and others added 11 commits October 15, 2022 12:16
* Render paragraphs

* Update CI workflow
* Enable code coverage

* Implement image loading

* Render single-image paragraphs

* Update workflows

* Render paragraphs with multiple images and no text

* Run swift format

* Test image links in multi-image paragraphs
* Parse list nodes

* Render numbered lists

* Render bulleted lists

* Render task lists
* Implement an inline content builder

* Implement the markdown content builder

* Implement list content builder

* Make inline and block types internal
# Conflicts:
#	Package.resolved
#	Package.swift
#	Tests/MarkdownUITests/MarkdownTests.swift
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testBlockQuote.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testBulletList.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testCodeBlock.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testCodeBlock.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testCodeBlockInsideList.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testCodeBlockInsideList.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testHeadings.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testHeadingsAndBlockQuotesInsideList.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testInlines.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testInlines.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testLinespacing.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testLinespacing.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testListAndHeadingsInsideBlockQuotes.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testMarkdownStyle.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testMarkdownStyle.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testOpenCodeBlock.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testOrderedList.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testParagraph.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testParagraphAndLineBreak.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testRightToLeftParagraph.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testRightToLeftParagraph.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testRightToLeftTrailingParagraph.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testRightToLeftTrailingParagraph.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testTrailingParagraph.iOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testTrailingParagraph.tvOS.png
#	Tests/MarkdownUITests/__Snapshots__/MarkdownTests/testVerbatimHTML.tvOS.png
* Parse blockquote

* Render blockquote
* Parse headings

* Rename BlockSpacingModifier/Preference to BottomPadingModifier/Preference

* Add TopPaddingModifier/Preference

* Render headings

* Add a single font heading style
@nicksiscoe
Copy link

Just droppin' in to provide moral support - This will be a game-changing PR ;)

* Scale spacing preference relative to body

* Scale spacing before preference relative to body

* Make spacing and spacingBefore preferences optional

* Refactor image, blockquote, paragraph and heading styles into a single type

* Refactor list marker styles

* Remove TaskListItemStyle

* Refactor spaced sequence into its own view type

* Rename default block style and code inline style

* Refactor some block views into ApplyBlockStyle view
…k and the bottom spacing of its predecessor (#155)
* Parse thematic breaks

* Render thematic breaks
* Parse code blocks

* Render code blocks
* Parse tables

* Render tables

* Fix markdown content table test availability

* Add table border style to theme

* Add image flow spacing to theme

* Add table rendering tests

* Tweak perceptual precision in the markdown table snapshot tests
* Add FontStyle and Size

* Polish FontStyle public API
* Add dynamic color extension

* Add a basic theme

* Add DocC theme

* Fix block spacing logic

* Update theme initializer

* Add DocC theme tests

* Add GitHub theme
* Update basic theme code block style

* Add watchOS support
@gonzalezreal gonzalezreal mentioned this pull request Dec 16, 2022
* Prevent some tests from running on iOS <16

* Add Swift Package Index manifest for documentation hosting

* Add a new demo project

* Add demo contents

* Remove commented code

* Set the GitHub theme as the default
* Add ImageProvider API

* Add images sample code

* Add image providers demo
* Text styles

* Heading styles

* More block styles

* List marker styles

* Table and thematic break styles

* Adopt refactored styles

* Code cleanup

* Update sample code

* Rename TextStyle protocol

* Update sample code

* Disable font properties test in tvOS
@gonzalezreal gonzalezreal changed the title [WIP] GitHub Flavored Markdown and native SwiftUI rendering GitHub Flavored Markdown and native SwiftUI rendering Jan 21, 2023
@gonzalezreal gonzalezreal marked this pull request as ready for review January 21, 2023 18:55
* WIP

* WIP

* WIP

* Disambiguate size-related View methods

* Update demo

* WIP

* Rename `Size` to `RelativeSize`

* WIP

* WIP

* WIP

* WIP

Fix relative URLs and heading anchor navigation

* WIP

* WIP
@gonzalezreal gonzalezreal force-pushed the gfm-and-swiftui-native-rendering branch from 5605c2f to a538390 Compare January 22, 2023 07:02
@gonzalezreal gonzalezreal merged commit cceb443 into main Jan 22, 2023
@gonzalezreal gonzalezreal deleted the gfm-and-swiftui-native-rendering branch January 22, 2023 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants