diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..058e21e --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,23 @@ +name: Setup +description: Setup Build Step +inputs: + node-version: + required: true + default: '18.x' + +runs: + using: "composite" + steps: + - uses: pnpm/action-setup@v3 + with: + version: 8.2.0 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: ${{ inputs.node-version }} + cache: 'pnpm' + + - name: Install dependencies + shell: bash + run: pnpm install diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 353a1dd..9148a71 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Prism React Renderer Release Workflow +name: Release Workflow on: push: @@ -19,25 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v3 - with: - version: 8.2.0 - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm install + - uses: ./.github/actions/setup - name: Build packages run: pnpm run build diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index e4d5139..cc8179b 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -5,7 +5,8 @@ on: branches: - master pull_request: - workflow_dispatch: + branches: + - master jobs: static-analysis: @@ -14,29 +15,19 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v3 - with: - version: 8.2.0 - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm install + - uses: ./.github/actions/setup - name: Build library run: pnpm run build + - name: Type Check run: pnpm run typecheck + - name: Lint run: pnpm run lint + + - name: Generate language definitions + run: pnpm run build:languages + + - name: Unit Test + run: pnpm run test diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml deleted file mode 100644 index 55a7776..0000000 --- a/.github/workflows/unit-test.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Unit Test - -on: - push: - branches: - - master - pull_request: - workflow_dispatch: - -jobs: - matrix: - name: 'Node 18' - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 - with: - node-version: 18 - - - uses: pnpm/action-setup@v3 - with: - version: 8.2.0 - - name: Get pnpm store directory - id: pnpm-cache - shell: bash - run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT - - uses: actions/cache@v4 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: ${{ runner.os }}-pnpm-store- - - name: Install dependencies - run: pnpm install - - - name: Generate language definitions - run: pnpm run build:languages - - - name: Unit Test - run: pnpm run test - diff --git a/LICENSE b/LICENSE index 0d5e37e..8915d38 100755 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2018 Formidable +Copyright (c) 2018 Nearform Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 6b82f49..c03f2af 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,26 @@ - - + +
- A lean Prism highlighter component for React
- Comes with everything to render Prismjs highlighted code directly to React (Native) elements, global-pollution-free!
+ A lean Prism highlighter component for React
+ + + + + +
-Maybe you need to render some extra UI with your Prismjs-highlighted code, -or maybe you'd like to manipulate what Prism renders completely, -or maybe you're just using Prism with React and are searching for an easier, -global-pollution-free way? ++ Comes with everything to render Prismjs syntax highlighted code directly in React & React Native! +
-Then you're right where you want to be! +## Introduction -## How? +Prism React Renderer powers syntax highlighting in the amazing [Docusaurus](https://docusaurus.io/) framework and many others. This library tokenises code using Prism and provides a small render-props-driven component to quickly render it out into React. This is why it even works with @@ -58,6 +61,7 @@ _(If you just want to use your Prism CSS-file themes, that's also no problem)_ - [`normalizeTokens`](#normalizetokens) - [`useTokenize`](#usetokenize) - [Theming](#theming) +- [Upgrading from v1 to v2](#upgrade) - [LICENSE](#license) - [Maintenance Status](#maintenance-status) @@ -121,14 +125,18 @@ export const App = () => ( ) -ReactDOM.createRoot(document.getElementById("root") as HTMLElement) - .render(