Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrodriguez committed Jan 2, 2024
0 parents commit 179bfda
Show file tree
Hide file tree
Showing 7 changed files with 449 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish Package to npmjs
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '18.9'
registry-url: 'https://registry.npmjs.org'
- run: npm install --frozen-lockfile
- run: npm ci
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100 changes: 100 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package-lock.json
yarn.lock

# Created by https://www.gitignore.io/api/node
# Edit at https://www.gitignore.io/?templates=node

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# react / gatsby
public/

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# End of https://www.gitignore.io/api/node
9 changes: 9 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules/
demo/
src/

.git
.gitignore
.npmignore
gulpfile.js
screenshot.png
147 changes: 147 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Mikroways Reveal common configuration

This package only provides a common configuration for all Mikroways courses.
It is a single point of configuration for every course, giving us the power of
change themes, plugin settings and other options upgrading this package.

## Common configurations

* **`reveal-md.json`:** this file allows a [reveal-md](https://github.com/webpro/reveal-md)
project to set common configurations.
* **`preproc.js`:** reveal-md preprocessor to be used within reveal-md
presentations. It allows to easily import code sinppets from external files,
other Markdown files, set slides styles, audio slides, and more.

## Usage

Simple add this package as dependency and configure
[postinstall](https://www.npmjs.com/package/postinstall):

```
npm i --save @mikroways/reveal-md-common
```

Add the followig scripts and corresponding hooks into `package.json`:

```json
"prestart": "postinstall",
"prestatic": "postinstall",
"start": "reveal-md src/start.md --preprocessor preproc.js --watch",
"static": "reveal-md src/start.md --preprocessor preproc.js --static",
...
},
"prepare": {
"reveal.js-mikroways/preproc.js": "link preproc.js",
"reveal.js-mikroways/reveal-md.json": "link reveal-md.json"
},
"prestart": {
"reveal.js-mikroways/preproc.js": "link preproc.js",
"reveal.js-mikroways/reveal-md.json": "link reveal-md.json"
},
"prestatic": {
"reveal.js-mikroways/preproc.js": "link preproc.js",
"reveal.js-mikroways/reveal-md.json": "link reveal-md.json"
},
...
```

> This configuration will run on **preprare**, **prestart** and **prestatic**
> life cycle events.
## Preprocessor helper functions


Reveal-md project now accepts Mikroways configurations that are read from
reveal-md.json file within a new *mikroways* options that accepts the following
configuration:

```yaml
mikroways:
# Will print debug information
debug: false
# Base path to look for files
basePath: 'src'
# Base path to look for code blocks to import
codePath: 'code'
# Custom named slide formats
formats:
main: 'class="main-cover" data-transition="zoom"'
new-topic: 'class="dark-logo-left" data-transition="zoom"'
new-topic-center: 'class="dark-logo-center" data-transition="zoom"'
```
> Values are the current default configuration
This configurations are used by **helper functions** provided by our custom
preprocesor, `preproc.js`. This helpers are:

* **`SLIDE_FMT: format-name[, extra string]`:** format-name is one of the
formats configured by `mikroways.format`. A comma is needed to append any
string.
* **`FILE: path/to/file.md`:** will load an external file that will be located
under `mikroways.basePath` named `path/to/file.md`. This allows to organize
courses in a better way.
* **`CODE: path/to/code.ext highlight [lines] [class=name]`:** loads a
highlighted code using syntax highlighting from an external file. This file
will be located under `mikroways.codePath` named `path/to/code.ext`. Note that
**highlight** is needed. Also accepts numbers to highlight specific lines,
separated with comma or dash. After, a custom class can be set to change some
styles.

## Example usage

Change slide format:

```
---
SLIDE_FMT: main
# Any title
---
```
> Will set slide format to `<!-- .slide: class="main-cover"
> data-transition="zoom" -->` with default configuration.

Extra options can be added:

```
---
SLIDE_FMT: main, data-transition-spped="fast"
# Any title
---
```

> Will set slide format to `<!-- .slide: class="main-cover"
> data-transition="zoom" data-transition-spped="fast" -->`.

To load an external file:

```
FILE: sections/some-slide.md
```
> Will load `some-slide.md` from a file located at `mikroways.basePath` and in
> this case, inside `sections/` directory.

A highlighted code example:

```
CODE: example.sh bash
```
> Will look for example.sh file inside `mikroways.basePath`, under directory
> `mikroways.codePath`. By default this is `src/code`. After the filename, it
> requires a language highlight configuration, in this case we specify bash
> script.

Now we will highlight only lines 1, and from 3 to 6:

```
CODE: example.sh bash 1,3-6
```

Finally, is possible to add a custom class:

```
CODE: example.sh bash 1,3-6 class="my-code"
CODE: example.sh bash class="my-code"
```
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@mikroways/reveal-md-common",
"version": "1.0.0",
"description": "Default configuration to work with Mikroways presentations",
"main": "preproc.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"mikroways",
"reveal-md"
],
"dependencies": {
"postinstall": "^0.9.0"
},
"author": "Christian Rodriguez",
"license": "ISC"
}
Loading

0 comments on commit 179bfda

Please sign in to comment.