├── .circleci └── config.yml ├── .editorconfig ├── .eslintrc.js ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── dependabot.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── .prettierrc ├── .sasslintrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── LICENSE.md ├── README.md ├── babel.config.js ├── commitlint.config.js ├── demos └── basic │ ├── .gitignore │ ├── README.md │ ├── _project │ ├── _images │ │ ├── b-ber-logo.png │ │ └── default-publishers-logo.png │ ├── _javascripts │ │ └── application.js │ ├── _markdown │ │ ├── project-name-chapter-01.md │ │ ├── project-name-colophon.md │ │ └── project-name-title-page.md │ ├── _stylesheets │ │ └── b-ber-theme-serif │ │ │ ├── _overrides.scss │ │ │ └── _settings.scss │ ├── epub.yml │ ├── metadata.yml │ ├── mobi.yml │ ├── pdf.yml │ ├── reader.yml │ ├── sample.yml │ └── web.yml │ └── config.yml ├── jest.config.js ├── lerna.json ├── package-lock.json ├── package.json ├── packages ├── b-ber-cli │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── commands │ │ │ ├── cover.test.js │ │ │ ├── generate.test.js │ │ │ ├── new.test.js │ │ │ ├── opf.test.js │ │ │ ├── serve.test.js │ │ │ ├── theme.test.js │ │ │ └── xml.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── app.js │ │ ├── commands │ │ ├── build.js │ │ ├── check.js │ │ ├── cover.js │ │ ├── deploy.js │ │ ├── generate.js │ │ ├── index.js │ │ ├── new.js │ │ ├── opf.js │ │ ├── serve.js │ │ ├── theme.js │ │ └── xml.js │ │ ├── index.js │ │ └── lib │ │ └── config-options.js ├── b-ber-grammar-attributes │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-audio-video │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── helpers.js │ │ └── index.js ├── b-ber-grammar-dialogue │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-epigraph │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-footnotes │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-frontmatter │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-gallery │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-iframe │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── helpers.js │ │ └── index.js ├── b-ber-grammar-image │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── image.js │ │ └── index.js ├── b-ber-grammar-logo │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-media │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── helpers.js │ │ └── index.js ├── b-ber-grammar-pullquote │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-renderer │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-section │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-spread │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-grammar-vimeo │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── helpers.js │ │ └── index.js ├── b-ber-lib │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ ├── props.test.js │ │ └── state.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── Config.js │ │ ├── EbookConvert.js │ │ ├── GuideItem.js │ │ ├── Html.js │ │ ├── HtmlToXml.js │ │ ├── ManifestItemProperties.js │ │ ├── Spine.js │ │ ├── SpineItem.js │ │ ├── State.js │ │ ├── Template.js │ │ ├── Theme.js │ │ ├── Url.js │ │ ├── Yaml.js │ │ ├── YamlAdaptor.js │ │ ├── index.js │ │ └── utils │ │ └── index.js ├── b-ber-logger │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── Timer.js │ │ ├── compose.js │ │ ├── configure.js │ │ ├── context.js │ │ ├── debug.js │ │ ├── error.js │ │ ├── events.js │ │ ├── format.js │ │ ├── indenter.js │ │ ├── index.js │ │ ├── info.js │ │ ├── inspect.js │ │ ├── listeners.js │ │ ├── notice.js │ │ ├── print-version.js │ │ ├── printer.js │ │ ├── register.js │ │ ├── reset.js │ │ ├── summary.js │ │ ├── trace.js │ │ └── warn.js ├── b-ber-markdown-renderer │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── highlightjs │ │ ├── highlight.js │ │ ├── index.js │ │ └── languages │ │ │ ├── 1c.js │ │ │ ├── abnf.js │ │ │ ├── accesslog.js │ │ │ ├── actionscript.js │ │ │ ├── ada.js │ │ │ ├── angelscript.js │ │ │ ├── apache.js │ │ │ ├── applescript.js │ │ │ ├── arcade.js │ │ │ ├── arduino.js │ │ │ ├── armasm.js │ │ │ ├── asciidoc.js │ │ │ ├── aspectj.js │ │ │ ├── autohotkey.js │ │ │ ├── autoit.js │ │ │ ├── avrasm.js │ │ │ ├── awk.js │ │ │ ├── axapta.js │ │ │ ├── bash.js │ │ │ ├── basic.js │ │ │ ├── bnf.js │ │ │ ├── brainfuck.js │ │ │ ├── cal.js │ │ │ ├── capnproto.js │ │ │ ├── ceylon.js │ │ │ ├── clean.js │ │ │ ├── clojure-repl.js │ │ │ ├── clojure.js │ │ │ ├── cmake.js │ │ │ ├── coffeescript.js │ │ │ ├── coq.js │ │ │ ├── cos.js │ │ │ ├── cpp.js │ │ │ ├── crmsh.js │ │ │ ├── crystal.js │ │ │ ├── cs.js │ │ │ ├── csp.js │ │ │ ├── css.js │ │ │ ├── d.js │ │ │ ├── dart.js │ │ │ ├── delphi.js │ │ │ ├── diff.js │ │ │ ├── django.js │ │ │ ├── dns.js │ │ │ ├── dockerfile.js │ │ │ ├── dos.js │ │ │ ├── dsconfig.js │ │ │ ├── dts.js │ │ │ ├── dust.js │ │ │ ├── ebnf.js │ │ │ ├── elixir.js │ │ │ ├── elm.js │ │ │ ├── erb.js │ │ │ ├── erlang-repl.js │ │ │ ├── erlang.js │ │ │ ├── excel.js │ │ │ ├── fix.js │ │ │ ├── flix.js │ │ │ ├── fortran.js │ │ │ ├── fsharp.js │ │ │ ├── gams.js │ │ │ ├── gauss.js │ │ │ ├── gcode.js │ │ │ ├── gherkin.js │ │ │ ├── glsl.js │ │ │ ├── gml.js │ │ │ ├── go.js │ │ │ ├── golo.js │ │ │ ├── gradle.js │ │ │ ├── groovy.js │ │ │ ├── haml.js │ │ │ ├── handlebars.js │ │ │ ├── haskell.js │ │ │ ├── haxe.js │ │ │ ├── hsp.js │ │ │ ├── htmlbars.js │ │ │ ├── http.js │ │ │ ├── hy.js │ │ │ ├── inform7.js │ │ │ ├── ini.js │ │ │ ├── irpf90.js │ │ │ ├── isbl.js │ │ │ ├── java.js │ │ │ ├── javascript.js │ │ │ ├── jboss-cli.js │ │ │ ├── json.js │ │ │ ├── julia-repl.js │ │ │ ├── julia.js │ │ │ ├── kotlin.js │ │ │ ├── lasso.js │ │ │ ├── ldif.js │ │ │ ├── leaf.js │ │ │ ├── less.js │ │ │ ├── lisp.js │ │ │ ├── livecodeserver.js │ │ │ ├── livescript.js │ │ │ ├── llvm.js │ │ │ ├── lsl.js │ │ │ ├── lua.js │ │ │ ├── makefile.js │ │ │ ├── markdown.js │ │ │ ├── mathematica.js │ │ │ ├── matlab.js │ │ │ ├── maxima.js │ │ │ ├── mel.js │ │ │ ├── mercury.js │ │ │ ├── mipsasm.js │ │ │ ├── mizar.js │ │ │ ├── mojolicious.js │ │ │ ├── monkey.js │ │ │ ├── moonscript.js │ │ │ ├── n1ql.js │ │ │ ├── nginx.js │ │ │ ├── nimrod.js │ │ │ ├── nix.js │ │ │ ├── nsis.js │ │ │ ├── objectivec.js │ │ │ ├── ocaml.js │ │ │ ├── openscad.js │ │ │ ├── oxygene.js │ │ │ ├── parser3.js │ │ │ ├── perl.js │ │ │ ├── pf.js │ │ │ ├── pgsql.js │ │ │ ├── php.js │ │ │ ├── plaintext.js │ │ │ ├── pony.js │ │ │ ├── powershell.js │ │ │ ├── processing.js │ │ │ ├── profile.js │ │ │ ├── prolog.js │ │ │ ├── properties.js │ │ │ ├── protobuf.js │ │ │ ├── puppet.js │ │ │ ├── purebasic.js │ │ │ ├── python.js │ │ │ ├── q.js │ │ │ ├── qml.js │ │ │ ├── r.js │ │ │ ├── reasonml.js │ │ │ ├── rib.js │ │ │ ├── roboconf.js │ │ │ ├── routeros.js │ │ │ ├── rsl.js │ │ │ ├── ruby.js │ │ │ ├── ruleslanguage.js │ │ │ ├── rust.js │ │ │ ├── sas.js │ │ │ ├── scala.js │ │ │ ├── scheme.js │ │ │ ├── scilab.js │ │ │ ├── scss.js │ │ │ ├── shell.js │ │ │ ├── smali.js │ │ │ ├── smalltalk.js │ │ │ ├── sml.js │ │ │ ├── sqf.js │ │ │ ├── sql.js │ │ │ ├── stan.js │ │ │ ├── stata.js │ │ │ ├── step21.js │ │ │ ├── stylus.js │ │ │ ├── subunit.js │ │ │ ├── swift.js │ │ │ ├── taggerscript.js │ │ │ ├── tap.js │ │ │ ├── tcl.js │ │ │ ├── tex.js │ │ │ ├── thrift.js │ │ │ ├── tp.js │ │ │ ├── twig.js │ │ │ ├── typescript.js │ │ │ ├── vala.js │ │ │ ├── vbnet.js │ │ │ ├── vbscript-html.js │ │ │ ├── vbscript.js │ │ │ ├── verilog.js │ │ │ ├── vhdl.js │ │ │ ├── vim.js │ │ │ ├── x86asm.js │ │ │ ├── xl.js │ │ │ ├── xml.js │ │ │ ├── xquery.js │ │ │ ├── yaml.js │ │ │ └── zephir.js │ │ └── index.js ├── b-ber-parser-dialogue │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-parser-figure │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-parser-footnotes │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── counter.js │ │ └── index.js ├── b-ber-parser-gallery │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-parser-section │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-reader-react │ ├── .browserslistrc │ ├── .eslintignore │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── .prettierignore │ ├── README.md │ ├── __tests__ │ │ ├── components │ │ │ ├── Audio.test.jsx │ │ │ ├── Library.test.jsx │ │ │ ├── Spinner.test.jsx │ │ │ ├── Video.test.jsx │ │ │ └── __snapshots__ │ │ │ │ ├── Audio.test.jsx.snap │ │ │ │ ├── Library.test.jsx.snap │ │ │ │ ├── Spinner.test.jsx.snap │ │ │ │ └── Video.test.jsx.snap │ │ ├── config.test.js │ │ ├── helpers │ │ │ ├── Asset.test.js │ │ │ ├── Types.test.js │ │ │ ├── Url.test.js │ │ │ ├── XMLAdaptor.test.js │ │ │ └── utils.test.js │ │ ├── lib │ │ │ ├── DocumentProcessor.test.js │ │ │ └── custom-prop-types.test.js │ │ └── models │ │ │ ├── BookMetadata.test.js │ │ │ ├── GuideItem.test.js │ │ │ ├── SpineItem.test.js │ │ │ └── ViewerSettings.test.js │ ├── dev │ │ ├── index.ejs │ │ └── index.example.js │ ├── index.d.ts │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ ├── scripts │ │ ├── analyze.sh │ │ ├── build.sh │ │ ├── start.sh │ │ ├── watch.sh │ │ └── webpack.sh │ ├── src │ │ ├── actions │ │ │ ├── markers.js │ │ │ ├── reader-location.js │ │ │ ├── reader-settings.js │ │ │ ├── user-interface.js │ │ │ ├── view.js │ │ │ └── viewer-settings.js │ │ ├── components │ │ │ ├── App.jsx │ │ │ ├── Controls.jsx │ │ │ ├── Footnote.jsx │ │ │ ├── Frame.jsx │ │ │ ├── Layout.jsx │ │ │ ├── Library.jsx │ │ │ ├── Link.jsx │ │ │ ├── Marker.jsx │ │ │ ├── Media │ │ │ │ ├── Audio.jsx │ │ │ │ ├── AudioElement.jsx │ │ │ │ ├── Controls │ │ │ │ │ ├── AudioControls.jsx │ │ │ │ │ ├── AudioControlsFull.jsx │ │ │ │ │ ├── AudioControlsNormal.jsx │ │ │ │ │ ├── AudioControlsSimple.jsx │ │ │ │ │ ├── AudioVideoControls.jsx │ │ │ │ │ ├── MediaButtonDownload.jsx │ │ │ │ │ ├── MediaButtonFullScreen.jsx │ │ │ │ │ ├── MediaButtonLoop.jsx │ │ │ │ │ ├── MediaButtonPlayPause.jsx │ │ │ │ │ ├── MediaButtonPlaybackRate.jsx │ │ │ │ │ ├── MediaButtonSeek.jsx │ │ │ │ │ ├── MediaButtonVolume.jsx │ │ │ │ │ ├── MediaControls.jsx │ │ │ │ │ ├── MediaRangeSlider.jsx │ │ │ │ │ ├── MediaTime.jsx │ │ │ │ │ ├── VideoControls.jsx │ │ │ │ │ ├── VideoControlsFull.jsx │ │ │ │ │ ├── VideoControlsNormal.jsx │ │ │ │ │ └── VideoControlsSimple.jsx │ │ │ │ ├── Iframe.jsx │ │ │ │ ├── Media.jsx │ │ │ │ ├── Video.jsx │ │ │ │ ├── VideoElement.jsx │ │ │ │ ├── Vimeo.jsx │ │ │ │ ├── VimeoPlayerControls.jsx │ │ │ │ └── VimeoPosterImage.jsx │ │ │ ├── Navigation │ │ │ │ ├── Icon.jsx │ │ │ │ ├── NavigationFooter.jsx │ │ │ │ ├── NavigationHeader.jsx │ │ │ │ └── index.js │ │ │ ├── Reader │ │ │ │ ├── index.jsx │ │ │ │ ├── loader.js │ │ │ │ ├── navigation.js │ │ │ │ └── resize.js │ │ │ ├── Sidebar │ │ │ │ ├── SidebarChapters.jsx │ │ │ │ ├── SidebarDownloads.jsx │ │ │ │ ├── SidebarMetadata.jsx │ │ │ │ ├── SidebarSettings.jsx │ │ │ │ └── index.js │ │ │ ├── Spinner.jsx │ │ │ ├── Spread.jsx │ │ │ ├── SpreadFigure.jsx │ │ │ ├── SpreadImageStyles.jsx │ │ │ ├── Ultimate.jsx │ │ │ └── index.js │ │ ├── config.js │ │ ├── constants │ │ │ ├── index.js │ │ │ ├── markers.js │ │ │ ├── reader-location.js │ │ │ ├── reader-settings.js │ │ │ ├── user-interface.js │ │ │ ├── view.js │ │ │ └── viewer-settings.js │ │ ├── fonts │ │ │ ├── CrimsonPro-Light.ttf │ │ │ ├── CrimsonPro-Medium.ttf │ │ │ ├── CrimsonPro-Regular.ttf │ │ │ └── CrimsonPro-SemiBold.ttf │ │ ├── helpers │ │ │ ├── Asset.js │ │ │ ├── Cache.js │ │ │ ├── DOM.js │ │ │ ├── Request.js │ │ │ ├── Storage.js │ │ │ ├── Types.js │ │ │ ├── Url.js │ │ │ ├── Viewport.js │ │ │ ├── XMLAdaptor.js │ │ │ ├── media.js │ │ │ ├── search-params.js │ │ │ └── utils.js │ │ ├── hooks │ │ │ └── use-max-height.js │ │ ├── index.jsx │ │ ├── index.scss │ │ ├── lib │ │ │ ├── DocumentPreProcessor.js │ │ │ ├── DocumentProcessor.js │ │ │ ├── History.js │ │ │ ├── Messenger.js │ │ │ ├── browser.js │ │ │ ├── custom-prop-types.js │ │ │ ├── multi-column-styles.js │ │ │ ├── polyfills.js │ │ │ ├── process-nodes.js │ │ │ ├── reader-context.js │ │ │ ├── request-animation-frame.js │ │ │ ├── spread-context.js │ │ │ ├── transition-styles.js │ │ │ ├── with-deferred-callbacks.jsx │ │ │ ├── with-dimensions.jsx │ │ │ ├── with-iframe-position.jsx │ │ │ ├── with-navigation-actions.js │ │ │ ├── with-node-position.jsx │ │ │ └── with-observers.jsx │ │ ├── models │ │ │ ├── BookMetadata.js │ │ │ ├── DeferredEvent.js │ │ │ ├── GuideItem.js │ │ │ ├── MediaStyleSheet.js │ │ │ ├── PageEvent.js │ │ │ ├── Script.js │ │ │ ├── SpineItem.js │ │ │ ├── ViewerSettings.js │ │ │ └── index.js │ │ ├── reducers │ │ │ ├── index.js │ │ │ ├── markers.js │ │ │ ├── reader-location.js │ │ │ ├── reader-settings.js │ │ │ ├── user-interface.js │ │ │ ├── view.js │ │ │ └── viewer-settings.js │ │ └── styles │ │ │ ├── _controls.scss │ │ │ ├── _fonts.scss │ │ │ ├── _footnote.scss │ │ │ ├── _icons.scss │ │ │ ├── _layout.scss │ │ │ ├── _media.scss │ │ │ ├── _mixins.scss │ │ │ ├── _print.scss │ │ │ ├── _spinner.scss │ │ │ └── _variables.scss │ └── webpack │ │ ├── common.js │ │ ├── config.custom-example.js │ │ ├── config.development.js │ │ ├── config.production.js │ │ ├── loaders.js │ │ └── plugins.js ├── b-ber-reader │ ├── .babelrc │ ├── .eslintrc │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── epub │ │ └── .keep │ ├── index.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ ├── server.js │ ├── src │ │ ├── index.js │ │ └── template.ejs │ └── webpack.config.js ├── b-ber-resources │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── b-ber-logo.png │ ├── default-publishers-logo.png │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-shapes-directives │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ └── index.js ├── b-ber-shapes-dublin-core │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── elements.js │ │ ├── index.js │ │ └── terms.js ├── b-ber-shapes-sequences │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ └── index.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── create-build-sequence.js │ │ ├── index.js │ │ └── sequences │ │ └── index.js ├── b-ber-tasks │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ ├── opf.test.js │ │ └── serialize.test.js │ ├── copy.sh │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── clean │ │ └── index.js │ │ ├── container │ │ └── index.js │ │ ├── copy │ │ └── index.js │ │ ├── cover │ │ ├── freeuniversal-bold-webfont.ttf │ │ └── index.js │ │ ├── deploy │ │ └── index.js │ │ ├── epub │ │ └── index.js │ │ ├── footnotes │ │ └── index.js │ │ ├── generate │ │ └── index.js │ │ ├── index.js │ │ ├── init │ │ └── index.js │ │ ├── inject │ │ └── index.js │ │ ├── loi │ │ └── index.js │ │ ├── mobi │ │ ├── index.js │ │ └── mobi-css.js │ │ ├── opf │ │ ├── ManifestAndMetadata.js │ │ ├── Navigation.js │ │ ├── Opf.js │ │ ├── helpers.js │ │ └── index.js │ │ ├── pdf │ │ └── index.js │ │ ├── reader │ │ └── index.js │ │ ├── render │ │ └── index.js │ │ ├── sample │ │ └── index.js │ │ ├── sass │ │ └── index.js │ │ ├── scripts │ │ └── index.js │ │ ├── serialize.js │ │ ├── serve │ │ └── index.js │ │ ├── validate │ │ └── index.js │ │ ├── web │ │ ├── Template.js │ │ ├── event-handlers.js │ │ ├── index.js │ │ ├── navigation.js │ │ ├── search.js │ │ └── worker.js │ │ └── xml │ │ └── index.js ├── b-ber-templates │ ├── .editorconfig │ ├── .eslintrc.js │ ├── .gitignore │ ├── .npmrc │ ├── README.md │ ├── __tests__ │ │ ├── Project.test.js │ │ ├── Toc.test.js │ │ ├── Xhtml.test.js │ │ ├── Xml.test.js │ │ ├── __snapshots__ │ │ │ ├── Toc.test.js.snap │ │ │ ├── Xhtml.test.js.snap │ │ │ └── Xml.test.js.snap │ │ └── figures │ │ │ ├── __snapshots__ │ │ │ ├── epub.test.js.snap │ │ │ ├── mobi.test.js.snap │ │ │ ├── reader.test.js.snap │ │ │ └── web.test.js.snap │ │ │ ├── epub.test.js │ │ │ ├── mobi.test.js │ │ │ ├── reader.test.js │ │ │ └── web.test.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ └── src │ │ ├── Ncx │ │ └── index.js │ │ ├── Opf │ │ ├── Guide.js │ │ ├── Manifest.js │ │ ├── Metadata.js │ │ ├── Pkg.js │ │ ├── Spine.js │ │ └── index.js │ │ ├── Ops │ │ └── index.js │ │ ├── Project │ │ ├── README.md.js │ │ ├── application.js.js │ │ ├── gitignore.js │ │ ├── index.js │ │ ├── metadata.yml.js │ │ ├── project-name-chapter-01.md.js │ │ ├── project-name-colophon.md.js │ │ ├── project-name-title-page.md.js │ │ └── toc.yml.js │ │ ├── Toc │ │ └── index.js │ │ ├── Xhtml │ │ └── index.js │ │ ├── Xml │ │ └── index.js │ │ ├── figures │ │ ├── epub.js │ │ ├── helpers.js │ │ ├── index.js │ │ ├── mobi.js │ │ ├── reader.js │ │ └── web.js │ │ └── index.js ├── b-ber-theme-sans │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── _overrides.scss │ ├── _settings.scss │ ├── application.scss │ ├── fonts │ │ └── .keep │ ├── images │ │ └── .keep │ ├── index.js │ └── package.json ├── b-ber-theme-serif │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── _settings.scss │ ├── application.scss │ ├── fonts │ │ └── .keep │ ├── images │ │ └── .keep │ ├── index.js │ ├── layout │ │ ├── _container.scss │ │ ├── _epub.scss │ │ ├── _figure.scss │ │ ├── _helpers.scss │ │ ├── _layout.scss │ │ ├── _list.scss │ │ ├── _media-controls.scss │ │ ├── _print.scss │ │ ├── _reader.scss │ │ ├── _table.scss │ │ ├── _text.scss │ │ ├── _web.scss │ │ └── index.scss │ ├── package.json │ └── typography │ │ ├── _fonts.scss │ │ ├── _reset.scss │ │ └── index.scss └── b-ber-validator │ ├── .eslintrc.js │ ├── .gitignore │ ├── README.md │ ├── __mocks__ │ └── index.js │ ├── __tests__ │ └── index.js │ ├── jest-transform-upward.js │ ├── jest.config.js │ ├── package.json │ ├── src │ ├── TODO.md │ ├── colors.ts │ ├── combinators │ │ ├── close.ts │ │ ├── constrained.ts │ │ ├── eol.ts │ │ ├── eos.ts │ │ ├── lazy.ts │ │ ├── many.ts │ │ ├── map.ts │ │ ├── not.ts │ │ ├── oneOf.ts │ │ ├── optional.ts │ │ ├── regex.ts │ │ ├── required.ts │ │ ├── sequence.ts │ │ └── string.ts │ ├── index.ts │ ├── lib │ │ ├── failure.ts │ │ ├── flat.ts │ │ └── success.ts │ ├── report.ts │ ├── typings │ │ ├── b-ber-shapes-directives │ │ │ └── index.d.ts │ │ └── b-ber-validator │ │ │ └── index.d.ts │ └── validator.ts │ ├── tsconfig.build.json │ ├── tsconfig.eslint.json │ └── tsconfig.json ├── scripts ├── run-ci.js └── update-dev-dependencies.js ├── svgo.yml └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | insert_final_newline = true 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | end_of_line = lf 8 | 9 | [*.{js,json}] 10 | indent_style = space 11 | indent_size = 2 12 | 13 | [*.{md,markdown}] 14 | trim_trailing_whitespace = false 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Feature request 4 | about: Suggest an idea for this project 5 | title: '' 6 | labels: '' 7 | assignees: '' 8 | ---**Is your feature request related to a problem? Please describe.** 9 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 10 | 11 | **Describe the solution you'd like** 12 | A clear and concise description of what you want to happen. 13 | 14 | **Describe alternatives you've considered** 15 | A clear and concise description of any alternative solutions or features you've considered. 16 | 17 | **Additional context** 18 | Add any other context or screenshots about the feature request here. 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Fixes # 2 | 3 | ## Proposed Changes 4 | 5 | - ... 6 | - ... 7 | - ... 8 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | updates: 4 | - package-ecosystem: 'npm' 5 | directory: '/' 6 | schedule: 7 | interval: 'weekly' 8 | target-branch: 'develop' 9 | 10 | # Only require security updates, disable version updates 11 | open-pull-requests-limit: 0 12 | 13 | labels: 14 | - 'security' 15 | assignees: 16 | - 'msimmer' 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | lerna-debug.log 5 | /coverage 6 | *.gypi 7 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false, 4 | "singleQuote": true, 5 | "semi": false, 6 | "trailingComma": "es5", 7 | "printWidth": 80 8 | } 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | b-ber is a toolchain for creating publications in a variety of digital 2 | formats 3 | Copyright (C) 2018 Triple Canopy 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /demos/basic/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .tmp 3 | 4 | *.map 5 | *.epub 6 | *.mobi 7 | *.pdf 8 | 9 | node_modules 10 | npm-debug.log* 11 | bber-debug.log* 12 | 13 | /project* 14 | -------------------------------------------------------------------------------- /demos/basic/README.md: -------------------------------------------------------------------------------- 1 | 2 | # demos 3 | 4 | Created with [b-ber](https://github.com/triplecanopy/b-ber/) 5 | -------------------------------------------------------------------------------- /demos/basic/_project/_images/b-ber-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/demos/basic/_project/_images/b-ber-logo.png -------------------------------------------------------------------------------- /demos/basic/_project/_images/default-publishers-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/demos/basic/_project/_images/default-publishers-logo.png -------------------------------------------------------------------------------- /demos/basic/_project/_markdown/project-name-chapter-01.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Project Name Chapter One 3 | type: bodymatter 4 | --- 5 | 6 | ::: chapter:project-name_chapter-one 7 | 8 | # Chapter Title 9 | 10 | Chapter Contents 11 | 12 | ::: exit:project-name_chapter-one 13 | -------------------------------------------------------------------------------- /demos/basic/_project/_markdown/project-name-colophon.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Project Name Colophon 3 | type: colophon 4 | --- 5 | 6 | ::: colophon:project-name-colophon 7 | 8 | *Project Title* by Author 9 | 10 | Published by Publisher, 2019 11 | 12 | ::: subchapter:credits 13 | 14 | © 2019 *Project Title*, by Author. Texts and images copyright the author, unless otherwise stated. 15 | 16 | ::: exit:credits 17 | 18 | ::: logo:publishers-logo source:default-publishers-logo.png 19 | 20 | Publisher 21 | 1234 Street 22 | City, State Zip 23 | Country 24 | 25 | ::: logo:b-ber-logo source:b-ber-logo.png 26 | 27 | *Project Title* is a DRM-free ebook that uses [b-ber](https://github.com/triplecanopy/b-ber), software designed and developed by [Triple Canopy](https://canopycanopycanopy.com). 28 | 29 | ::: exit:project-name-colophon 30 | -------------------------------------------------------------------------------- /demos/basic/_project/_markdown/project-name-title-page.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Project Name Title Page 3 | type: titlepage 4 | --- 5 | 6 | ::: titlepage:project-name-title-page 7 | 8 | # Project Title by Author 9 | 10 | ::: exit:project-name-title-page 11 | -------------------------------------------------------------------------------- /demos/basic/_project/_stylesheets/b-ber-theme-serif/_overrides.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/demos/basic/_project/_stylesheets/b-ber-theme-serif/_overrides.scss -------------------------------------------------------------------------------- /demos/basic/_project/epub.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/_project/mobi.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/_project/pdf.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/_project/reader.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/_project/sample.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/_project/web.yml: -------------------------------------------------------------------------------- 1 | # Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | -------------------------------------------------------------------------------- /demos/basic/config.yml: -------------------------------------------------------------------------------- 1 | env: development 2 | src: _project 3 | dist: project 4 | ibooks_specified_fonts: false 5 | theme: b-ber-theme-serif 6 | themes_directory: ./themes 7 | base_url: / 8 | base_path: / 9 | remote_url: 'http://localhost:4000/' 10 | reader_url: 'http://localhost:4000/project-reader' 11 | builds: 12 | - epub 13 | - mobi 14 | - pdf 15 | ui_options: 16 | navigation: 17 | header_icons: 18 | info: true 19 | home: true 20 | downloads: true 21 | toc: true 22 | footer_icons: 23 | chapter: true 24 | page: true 25 | private: false 26 | ignore: [] 27 | autoprefixer_options: 28 | browsers: 29 | - last 2 versions 30 | - '> 2%' 31 | flexbox: no-2009 32 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "lerna": "4.0.0", 3 | "packages": ["packages/*"], 4 | "npmClient": "npm", 5 | "version": "3.1.0", 6 | "command": { 7 | "publish": { 8 | "message": "%v" 9 | }, 10 | "bootstrap": { 11 | "npmClientArgs": ["--no-package-lock"] 12 | }, 13 | "version": { 14 | "exact": true 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-cli/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-cli/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-cli/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-cli/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/cover.test.js: -------------------------------------------------------------------------------- 1 | import cover from '../../src/commands/cover' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | cover: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | })) 10 | 11 | jest.mock('@canopycanopycanopy/b-ber-lib/State', () => ({})) 12 | 13 | describe('cover', () => { 14 | it('exports a yargs command object', () => { 15 | expect(cover).toEqual( 16 | expect.objectContaining({ 17 | command: expect.anything(), 18 | describe: expect.any(String), 19 | builder: expect.any(Function), 20 | handler: expect.any(Function), 21 | }) 22 | ) 23 | }) 24 | }) 25 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/generate.test.js: -------------------------------------------------------------------------------- 1 | import generate from '../../src/commands/generate' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | generate: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | ensure: jest.fn(), 10 | })) 11 | 12 | describe('generate', () => { 13 | it('exports a yargs command object', () => { 14 | expect(generate).toEqual( 15 | expect.objectContaining({ 16 | command: expect.anything(), 17 | describe: expect.any(String), 18 | builder: expect.any(Function), 19 | handler: expect.any(Function), 20 | }) 21 | ) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/new.test.js: -------------------------------------------------------------------------------- 1 | import _new from '../../src/commands/new' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | _new: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | ensure: jest.fn(), 10 | })) 11 | 12 | describe('new', () => { 13 | it('exports a yargs command object', () => { 14 | expect(_new).toEqual( 15 | expect.objectContaining({ 16 | command: expect.anything(), 17 | describe: expect.any(String), 18 | builder: expect.any(Function), 19 | handler: expect.any(Function), 20 | }) 21 | ) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/opf.test.js: -------------------------------------------------------------------------------- 1 | import opf from '../../src/commands/opf' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | opf: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | ensure: jest.fn(), 10 | })) 11 | 12 | describe('opf', () => { 13 | it('exports a yargs command object', () => { 14 | expect(opf).toEqual( 15 | expect.objectContaining({ 16 | command: expect.anything(), 17 | describe: expect.any(String), 18 | builder: expect.any(Function), 19 | handler: expect.any(Function), 20 | }) 21 | ) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/serve.test.js: -------------------------------------------------------------------------------- 1 | import serve from '../../src/commands/serve' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | serve: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | ensure: jest.fn(), 10 | })) 11 | 12 | describe('serve', () => { 13 | it('exports a yargs command object', () => { 14 | expect(serve).toEqual( 15 | expect.objectContaining({ 16 | command: expect.anything(), 17 | describe: expect.any(String), 18 | builder: expect.any(Function), 19 | handler: expect.any(Function), 20 | }) 21 | ) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/theme.test.js: -------------------------------------------------------------------------------- 1 | import theme from '../../src/commands/theme' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-lib/Theme', () => ({})) 4 | 5 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 6 | theme: jest.fn(), 7 | })) 8 | 9 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 10 | fail: jest.fn(), 11 | ensure: jest.fn(), 12 | })) 13 | 14 | describe('theme', () => { 15 | it('exports a yargs command object', () => { 16 | expect(theme).toEqual( 17 | expect.objectContaining({ 18 | command: expect.anything(), 19 | describe: expect.any(String), 20 | builder: expect.any(Function), 21 | handler: expect.any(Function), 22 | }) 23 | ) 24 | }) 25 | }) 26 | -------------------------------------------------------------------------------- /packages/b-ber-cli/__tests__/commands/xml.test.js: -------------------------------------------------------------------------------- 1 | import xml from '../../src/commands/xml' 2 | 3 | jest.mock('@canopycanopycanopy/b-ber-tasks', () => ({ 4 | xml: jest.fn(), 5 | })) 6 | 7 | jest.mock('@canopycanopycanopy/b-ber-lib/utils', () => ({ 8 | fail: jest.fn(), 9 | ensure: jest.fn(), 10 | })) 11 | 12 | describe('xml', () => { 13 | it('exports a yargs command object', () => { 14 | expect(xml).toEqual( 15 | expect.objectContaining({ 16 | command: expect.anything(), 17 | describe: expect.any(String), 18 | builder: expect.any(Function), 19 | handler: expect.any(Function), 20 | }) 21 | ) 22 | }) 23 | }) 24 | -------------------------------------------------------------------------------- /packages/b-ber-cli/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-cli/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-cli', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/check.js: -------------------------------------------------------------------------------- 1 | import { validate } from '@canopycanopycanopy/b-ber-tasks' 2 | import { fail } from '@canopycanopycanopy/b-ber-lib/utils' 3 | 4 | const command = 'check [project]' 5 | 6 | const describe = 'Validate b-ber project Markdown' 7 | 8 | const builder = yargs => 9 | yargs 10 | .positional('project', { 11 | describe: 'Path to the b-ber project', 12 | type: 'string', 13 | }) 14 | .help('h') 15 | .alias('h', 'help') 16 | .fail((msg, err) => fail(msg, err, yargs)) 17 | .usage(`\nUsage: $0 check\n\n${describe}`) 18 | 19 | const handler = argv => { 20 | const project = argv.project || process.cwd() 21 | validate({ project }) 22 | } 23 | 24 | export default { 25 | command, 26 | describe, 27 | builder, 28 | handler, 29 | } 30 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/cover.js: -------------------------------------------------------------------------------- 1 | import { cover } from '@canopycanopycanopy/b-ber-tasks' 2 | import { fail } from '@canopycanopycanopy/b-ber-lib/utils' 3 | 4 | const command = 'cover' 5 | const describe = 'Generate a project cover' 6 | const builder = yargs => 7 | yargs 8 | .fail((msg, err) => fail(msg, err, yargs)) 9 | .help('h') 10 | .alias('h', 'help') 11 | .usage(`\nUsage: $0 cover\n\n${describe}`) 12 | 13 | const handler = () => cover.init() 14 | 15 | export default { 16 | command, 17 | describe, 18 | builder, 19 | handler, 20 | } 21 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/deploy.js: -------------------------------------------------------------------------------- 1 | import { deploy } from '@canopycanopycanopy/b-ber-tasks' 2 | import { fail } from '@canopycanopycanopy/b-ber-lib/utils' 3 | 4 | const command = 'deploy [builds...]' 5 | const describe = 'Upload a b-ber project to Amazon S3' 6 | const builder = yargs => 7 | yargs 8 | .option('yes', { 9 | alias: 'y', 10 | describe: 'Skip all confirmation prompts', 11 | type: 'boolean', 12 | }) 13 | .positional('builds', { 14 | describe: 'Builds to upload', 15 | choices: ['epub', 'mobi', 'reader', 'web', 'pdf', 'xml'], 16 | type: 'string', 17 | }) 18 | .help('h') 19 | .alias('h', 'help') 20 | .usage(`\nUsage: $0 deploy\n\n${describe}`) 21 | .fail((msg, err) => fail(msg, err, yargs)) 22 | 23 | const handler = deploy 24 | 25 | export default { 26 | command, 27 | describe, 28 | builder, 29 | handler, 30 | } 31 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/index.js: -------------------------------------------------------------------------------- 1 | export { default as build } from './build' 2 | export { default as cover } from './cover' 3 | export { default as deploy } from './deploy' 4 | export { default as generate } from './generate' 5 | export { default as new } from './new' 6 | export { default as opf } from './opf' 7 | export { default as serve } from './serve' 8 | export { default as theme } from './theme' 9 | export { default as check } from './check' 10 | // export { default as xml } from './xml' 11 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/opf.js: -------------------------------------------------------------------------------- 1 | import { opf } from '@canopycanopycanopy/b-ber-tasks' 2 | 3 | const command = 'opf' 4 | const describe = 'Generate the opf' 5 | const builder = yargs => 6 | yargs 7 | .help('h') 8 | .alias('h', 'help') 9 | .usage(`\nUsage: $0 opf\n\n${describe}`) 10 | 11 | const handler = opf 12 | 13 | export default { 14 | command, 15 | describe, 16 | builder, 17 | handler, 18 | } 19 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/commands/xml.js: -------------------------------------------------------------------------------- 1 | import { xml } from '@canopycanopycanopy/b-ber-tasks' 2 | 3 | const command = 'xml' 4 | const describe = 'Export a project as an XML document' 5 | 6 | const builder = yargs => 7 | yargs 8 | .help('h') 9 | .alias('h', 'help') 10 | .usage(`\nUsage: $0 xml\n\n${describe}`) 11 | 12 | const handler = xml 13 | 14 | export default { 15 | command, 16 | describe, 17 | builder, 18 | handler, 19 | } 20 | -------------------------------------------------------------------------------- /packages/b-ber-cli/src/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | import fs from 'fs-extra' 4 | 5 | if (process.argv.indexOf('--version') > -1) { 6 | console.log(fs.readJSONSync(require.resolve('../package.json')).version) 7 | } else { 8 | const bber = require('./app').default // eslint-disable-line global-require 9 | bber() 10 | } 11 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-attributes` 2 | 3 | The `b-ber-grammar-attributes` package is used internally by b-ber to parse the attributes of custom Markdown extensions. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-attributes 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-attributes/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-attributes', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-audio-video` 2 | 3 | The `b-ber-grammar-audio-video` package renders b-ber's custom `audio` and `video` Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-audio-video 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-audio-video', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-audio-video/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-audio-video', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-dialogue` 2 | 3 | The `b-ber-grammar-dialogue` package renders b-ber's custom `dialogue` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-dialogue 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-dialogue', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-dialogue/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-dialogue', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-epigraph` 2 | 3 | The `b-ber-grammar-epigraph` package renders b-ber's custom `epigraph` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-epigraph 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-epigraph', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-epigraph/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-epigraph', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-footnotes` 2 | 3 | The `b-ber-grammar-footnotes` package renders b-ber's custom `footnotes` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-footnotes 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-footnotes', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-footnotes/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-footnotes', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-frontmatter` 2 | 3 | The `b-ber-grammar-frontmatter` package renders b-ber's custom `frontmatter` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-frontmatter 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-frontmatter', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-frontmatter', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-frontmatter/src/index.js: -------------------------------------------------------------------------------- 1 | import state from '@canopycanopycanopy/b-ber-lib/State' 2 | import YamlAdaptor from '@canopycanopycanopy/b-ber-lib/YamlAdaptor' 3 | import { GuideItem } from '@canopycanopycanopy/b-ber-lib' 4 | 5 | export default function markdownItFrontmatterPlugin(self) { 6 | return function plugin(meta) { 7 | const { fileName } = self 8 | const YAMLMeta = YamlAdaptor.parse(meta) 9 | 10 | state.add('guide', new GuideItem({ fileName, ...YAMLMeta })) 11 | 12 | // merge the found entry in the state and spine so that we 13 | // can access the metadata later 14 | let data 15 | if ((data = state.spine.frontMatter.get(fileName))) { 16 | state.spine.frontMatter.set(fileName, { ...data, ...YAMLMeta }) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-gallery` 2 | 3 | The `b-ber-grammar-gallery` package renders b-ber's custom `gallery` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-gallery 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-gallery', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-gallery/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-gallery', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-iframe` 2 | 3 | The `b-ber-grammar-iframe` package renders b-ber's custom `iframe` Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-iframe 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-iframe', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-iframe/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-iframe', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-image` 2 | 3 | The `b-ber-grammar-image` package renders b-ber's custom `image` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-image 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-image', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-image/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-image', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-logo` 2 | 3 | The `b-ber-grammar-logo` package renders b-ber's custom `logo` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-logo 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-logo', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-logo/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-logo', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-media` 2 | 3 | The `b-ber-grammar-media` package renders b-ber's custom `audio` and `video` Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-media 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-media/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-media', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-pullquote` 2 | 3 | The `b-ber-grammar-pullquote` package renders b-ber's custom `pullquote` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-pullquote 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-pullquote', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-pullquote/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-pullquote', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-renderer` 2 | 3 | The `b-ber-grammar-renderer` package is used internally by b-ber to render containing custom Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-renderer 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-renderer', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-renderer/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-renderer', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-section` 2 | 3 | The `b-ber-grammar-section` package is used internally by b-ber to render custom Markdown extensions (directives) which contain content. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-section 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-section', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-section/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-section', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-spread` 2 | 3 | The `b-ber-grammar-spread` package renders b-ber's custom `spread` Markdown extension (directive) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-spread 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-spread', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-spread/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-spread', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-grammar-vimeo` 2 | 3 | The `b-ber-grammar-vimeo` package renders b-ber's custom `vimeo` Markdown extensions (directives) into HTML. More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-grammar-vimeo 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-grammar-vimeo', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-grammar-vimeo/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-grammar-vimeo', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-lib/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | 5 | /utils 6 | /*.js 7 | !/jest.config.js 8 | !/jest-transform-upward.js 9 | -------------------------------------------------------------------------------- /packages/b-ber-lib/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-lib/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-lib` 2 | 3 | The `b-ber-lib` package includes classes and modules for managing b-ber's internal state, performing I/O operations, and parsing and rendering YAML and JSON data. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-lib 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-lib/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = require('babel-jest').createTransformer({ 3 | rootMode: 'upward', 4 | }) 5 | -------------------------------------------------------------------------------- /packages/b-ber-lib/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-lib', 3 | 4 | verbose: false, 5 | setupFilesAfterEnv: ['jest-extended'], 6 | testURL: 'http://localhost/', 7 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-lib/src/GuideItem.js: -------------------------------------------------------------------------------- 1 | class GuideItem { 2 | constructor({ fileName, title, type }) { 3 | this.fileName = fileName 4 | this.title = title 5 | this.type = type 6 | } 7 | } 8 | 9 | export default GuideItem 10 | -------------------------------------------------------------------------------- /packages/b-ber-lib/src/Html.js: -------------------------------------------------------------------------------- 1 | class Html { 2 | static comment(str) { 3 | return `\n\n` 4 | } 5 | 6 | static escape(str) { 7 | const str_ = typeof str !== 'string' ? String(str) : str 8 | const map = { 9 | '&': '&', 10 | '<': '<', 11 | '>': '>', 12 | '"': '"', 13 | "'": ''', 14 | } 15 | return str_.replace(/[&<>"']/g, m => map[m]) 16 | } 17 | } 18 | 19 | export default Html 20 | -------------------------------------------------------------------------------- /packages/b-ber-lib/src/Template.js: -------------------------------------------------------------------------------- 1 | import File from 'vinyl' 2 | import renderLayouts from 'layouts' 3 | 4 | class Template { 5 | static render = (contents, template) => 6 | renderLayouts( 7 | new File({ 8 | path: '.Template', 9 | layout: 'template', 10 | contents: Buffer.from(contents), 11 | }), 12 | { template } 13 | ).contents.toString() 14 | } 15 | 16 | export default Template 17 | -------------------------------------------------------------------------------- /packages/b-ber-lib/src/index.js: -------------------------------------------------------------------------------- 1 | export { default as EbookConvert } from './EbookConvert' 2 | export { default as HtmlToXml } from './HtmlToXml' 3 | export { default as ManifestItemProperties } from './ManifestItemProperties' 4 | export { default as State } from './State' 5 | export { default as YamlAdaptor } from './YamlAdaptor' 6 | export { default as Theme } from './Theme' 7 | export { default as utils } from './utils' 8 | export { default as Url } from './Url' 9 | export { default as Html } from './Html' 10 | export { default as SpineItem } from './SpineItem' 11 | export { default as GuideItem } from './GuideItem' 12 | export { default as Spine } from './Spine' 13 | export { default as Template } from './Template' 14 | -------------------------------------------------------------------------------- /packages/b-ber-logger/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-logger/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-logger/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-logger/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-logger', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-logger/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-logger/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-logger', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/compose.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | import util from 'util' 4 | 5 | export function composeMessage(args) { 6 | const message = util.format 7 | .call(util, ...args) 8 | .split('\n') 9 | .map(a => a.trim()) 10 | .join(`\n${' '.repeat(6)}`) 11 | .replace(/\{(\d+)\}/g, (_, d) => 12 | this.decorate(String(this.floatFormat(d)), 'blueBright') 13 | ) 14 | .replace(/\[([^\]]+)\]/g, (_, s) => this.decorate(s, 'blueBright')) 15 | 16 | return message 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/configure.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function configure() { 4 | /* 5 | 6 | 0 quiet show nothing 7 | 1 error show only errors 8 | 2 warn show warnings and errors 9 | 3 info show minimal info 10 | 4 verbose show all info 11 | 5 debug show everything 12 | 13 | */ 14 | 15 | let logLevel 16 | logLevel = this.settings['log-level'] 17 | logLevel = this.settings.quiet ? 0 : logLevel 18 | logLevel = this.settings.verbose ? 4 : logLevel 19 | logLevel = this.settings.debug ? 5 : logLevel 20 | 21 | this.logLevel = logLevel 22 | 23 | this.boringOutput = this.settings['no-color'] || this.boringOutput 24 | this.summary = this.settings.summary || this.summary 25 | } 26 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/context.js: -------------------------------------------------------------------------------- 1 | import Timer from './Timer' 2 | 3 | function ctx(fileName) { 4 | return fileName 5 | // return path.basename(path.dirname(fileName)) + path.sep + path.basename(fileName, path.extname(fileName)) 6 | } 7 | 8 | export function counter() { 9 | this.incrementCounter() 10 | return this.decorate(`[${Timer.dateFormat()}]`) 11 | } 12 | export function getContext() { 13 | const { stack } = new Error() 14 | const message = stack.split('\n') 15 | const context = message[3].replace(/^\s+at[^/]+(\/[^:]+):.+$/, (_, m) => 16 | ctx(m) 17 | ) 18 | 19 | if (context !== this.context) { 20 | this.context = context 21 | } else { 22 | return '' 23 | } 24 | return context 25 | } 26 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/debug.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function debug() {} 4 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/events.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function notify(event, data) { 4 | this[event].call(this, data) 5 | } 6 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/indenter.js: -------------------------------------------------------------------------------- 1 | export function indent() { 2 | return this.whitespace.repeat(this.indentLevel) 3 | } 4 | export function incrementIndent() { 5 | this.indentLevel += this.increment 6 | } 7 | export function decrementIndent() { 8 | this.indentLevel -= this.increment 9 | } 10 | export function incrementCounter() { 11 | this.taskCounter += 1 12 | } 13 | export function decrementCounter() { 14 | this.taskCounter -= 1 15 | } 16 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/info.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | import util from 'util' 4 | 5 | export function info(...args) { 6 | if (this.logLevel < 4) return 7 | 8 | const message = this.decorate(this.composeMessage(args)) 9 | 10 | let prefix = '' 11 | 12 | if (this.logLevel > 2) { 13 | prefix += this.decorate(`[${new Date().toISOString()}]`, 'gray') 14 | prefix += ' ' 15 | } 16 | 17 | prefix += this.decorate('b-ber', 'whiteBright', 'bgBlack') 18 | prefix += ' ' 19 | prefix += this.decorate('info', 'green') 20 | prefix += ' ' 21 | 22 | process.stdout.write(`${prefix}${message}`) 23 | this.newLine() 24 | 25 | if (this.logLevel > 4) { 26 | const { stack } = new Error() 27 | process.stdout.write( 28 | util.format.call(util, stack.replace(/^Error\s+/, 'Info ')) 29 | ) 30 | this.newLine() 31 | this.newLine() 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/inspect.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | import util from 'util' 4 | 5 | export function inspect(args) { 6 | return console.log(util.inspect(args, true, null, true)) 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/notice.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | // same as info but always prints to log, i.e., log-level doesn't need to be set. 4 | export function notice(...args) { 5 | const message = this.decorate(this.composeMessage(args)) 6 | 7 | let prefix = '' 8 | 9 | if (this.logLevel > 2) { 10 | prefix += this.decorate(`[${new Date().toISOString()}]`, 'gray') 11 | prefix += ' ' 12 | } 13 | 14 | prefix += this.decorate('b-ber', 'whiteBright', 'bgBlack') 15 | prefix += ' ' 16 | prefix += this.decorate('info', 'green') 17 | prefix += ' ' 18 | 19 | process.stdout.write(`${prefix}${message}`) 20 | this.newLine() 21 | } 22 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/print-version.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | import util from 'util' 4 | 5 | export function printVersion(version) { 6 | const message = util.format.call( 7 | util, 8 | '%s%s %s %s', 9 | this.indent(), 10 | this.decorate('b-ber', 'whiteBright', 'bgBlack'), 11 | this.decorate('version'), 12 | this.decorate(version, 'blueBright') 13 | ) 14 | 15 | process.stdout.write(message) 16 | this.newLine() 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/printer.js: -------------------------------------------------------------------------------- 1 | import util from 'util' 2 | 3 | function printNotices(type, task = 'b-ber') { 4 | const notices = this[type] 5 | const leader = type === 'warnings' ? 'WARN' : 'ERR!' 6 | const color = type === 'warnings' ? 'bgYellowBright' : 'bgRed' 7 | 8 | const message = util.format.call( 9 | util, 10 | '%s%s %s task %s - %s %s', 11 | this.indent(), 12 | this.decorate('b-ber', 'whiteBright', 'bgBlack'), 13 | this.decorate(leader, color), 14 | this.decorate(task), 15 | this.decorate(notices.length), 16 | this.decorate(type) 17 | ) 18 | 19 | if (this.logLevel > 2) process.stdout.write(message) 20 | } 21 | 22 | export function printWarnings(task) { 23 | printNotices.call(this, 'warnings', task) 24 | } 25 | 26 | export function printErrors(task) { 27 | printNotices.call(this, 'errors', task) 28 | } 29 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/register.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function registerSequence(state, command, sequence) { 4 | if (this.logLevel < 1) return 5 | 6 | const message = this.decorate( 7 | this.composeMessage([ 8 | 'Preparing to run', 9 | sequence.length, 10 | `task${sequence.length > 1 ? 's' : ''}`, 11 | ]) 12 | ) 13 | 14 | let prefix = '' 15 | 16 | if (this.logLevel > 2) { 17 | prefix += this.decorate(`[${new Date().toISOString()}]`, 'gray') 18 | prefix += ' ' 19 | } 20 | 21 | prefix += this.decorate('b-ber', 'whiteBright', 'bgBlack') 22 | prefix += ' ' 23 | prefix += this.decorate('info', 'green') 24 | prefix += ' ' 25 | 26 | process.stdout.write(`${prefix}${message}`) 27 | this.newLine() 28 | } 29 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/reset.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function reset() { 4 | this.errors = [] 5 | this.warnings = [] 6 | // this.infos = [] 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-logger/src/trace.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export function trace() {} 4 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-markdown-renderer` 2 | 3 | The `b-ber-markdown-renderer` package is used internally to register the Markdown plugins and manage the rendering of Markdown to HTML. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-markdown-renderer 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-markdown-renderer', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-markdown-renderer', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/bnf.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs){ 2 | return { 3 | contains: [ 4 | // Attribute 5 | { 6 | className: 'attribute', 7 | begin: // 8 | }, 9 | // Specific 10 | { 11 | begin: /::=/, 12 | starts: { 13 | end: /$/, 14 | contains: [ 15 | { 16 | begin: // 17 | }, 18 | // Common 19 | hljs.C_LINE_COMMENT_MODE, 20 | hljs.C_BLOCK_COMMENT_MODE, 21 | hljs.APOS_STRING_MODE, 22 | hljs.QUOTE_STRING_MODE 23 | ] 24 | } 25 | } 26 | ] 27 | }; 28 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/brainfuck.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs){ 2 | var LITERAL = { 3 | className: 'literal', 4 | begin: '[\\+\\-]', 5 | relevance: 0 6 | }; 7 | return { 8 | aliases: ['bf'], 9 | contains: [ 10 | hljs.COMMENT( 11 | '[^\\[\\]\\.,\\+\\-<> \r\n]', 12 | '[\\[\\]\\.,\\+\\-<> \r\n]', 13 | { 14 | returnEnd: true, 15 | relevance: 0 16 | } 17 | ), 18 | { 19 | className: 'title', 20 | begin: '[\\[\\]]', 21 | relevance: 0 22 | }, 23 | { 24 | className: 'string', 25 | begin: '[\\.,]', 26 | relevance: 0 27 | }, 28 | { 29 | // this mode works as the only relevance counter 30 | begin: /\+\+|\-\-/, returnBegin: true, 31 | contains: [LITERAL] 32 | }, 33 | LITERAL 34 | ] 35 | }; 36 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/clean.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | aliases: ['clean','icl','dcl'], 4 | keywords: { 5 | keyword: 6 | 'if let in with where case of class instance otherwise ' + 7 | 'implementation definition system module from import qualified as ' + 8 | 'special code inline foreign export ccall stdcall generic derive ' + 9 | 'infix infixl infixr', 10 | built_in: 11 | 'Int Real Char Bool', 12 | literal: 13 | 'True False' 14 | }, 15 | contains: [ 16 | 17 | hljs.C_LINE_COMMENT_MODE, 18 | hljs.C_BLOCK_COMMENT_MODE, 19 | hljs.APOS_STRING_MODE, 20 | hljs.QUOTE_STRING_MODE, 21 | hljs.C_NUMBER_MODE, 22 | 23 | {begin: '->|<-[|:]?|#!?|>>=|\\{\\||\\|\\}|:==|=:|<>'} // relevance booster 24 | ] 25 | }; 26 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/clojure-repl.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | contains: [ 4 | { 5 | className: 'meta', 6 | begin: /^([\w.-]+|\s*#_)?=>/, 7 | starts: { 8 | end: /$/, 9 | subLanguage: 'clojure' 10 | } 11 | } 12 | ] 13 | } 14 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/csp.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | case_insensitive: false, 4 | lexemes: '[a-zA-Z][a-zA-Z0-9_-]*', 5 | keywords: { 6 | keyword: 'base-uri child-src connect-src default-src font-src form-action' + 7 | ' frame-ancestors frame-src img-src media-src object-src plugin-types' + 8 | ' report-uri sandbox script-src style-src', 9 | }, 10 | contains: [ 11 | { 12 | className: 'string', 13 | begin: "'", end: "'" 14 | }, 15 | { 16 | className: 'attribute', 17 | begin: '^Content', end: ':', excludeEnd: true, 18 | }, 19 | ] 20 | }; 21 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/dockerfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | aliases: ['docker'], 4 | case_insensitive: true, 5 | keywords: 'from maintainer expose env arg user onbuild stopsignal', 6 | contains: [ 7 | hljs.HASH_COMMENT_MODE, 8 | hljs.APOS_STRING_MODE, 9 | hljs.QUOTE_STRING_MODE, 10 | hljs.NUMBER_MODE, 11 | { 12 | beginKeywords: 'run cmd entrypoint volume add copy workdir label healthcheck shell', 13 | starts: { 14 | end: /[^\\]$/, 15 | subLanguage: 'bash' 16 | } 17 | } 18 | ], 19 | illegal: ''), 6 | { 7 | begin: '<%[%=-]?', end: '[%-]?%>', 8 | subLanguage: 'ruby', 9 | excludeBegin: true, 10 | excludeEnd: true 11 | } 12 | ] 13 | }; 14 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/fix.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | contains: [ 4 | { 5 | begin: /[^\u2401\u0001]+/, 6 | end: /[\u2401\u0001]/, 7 | excludeEnd: true, 8 | returnBegin: true, 9 | returnEnd: false, 10 | contains: [ 11 | { 12 | begin: /([^\u2401\u0001=]+)/, 13 | end: /=([^\u2401\u0001=]+)/, 14 | returnEnd: true, 15 | returnBegin: false, 16 | className: 'attr' 17 | }, 18 | { 19 | begin: /=/, 20 | end: /([\u2401\u0001])/, 21 | excludeEnd: true, 22 | excludeBegin: true, 23 | className: 'string' 24 | }] 25 | }], 26 | case_insensitive: true 27 | }; 28 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/golo.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | keywords: { 4 | keyword: 5 | 'println readln print import module function local return let var ' + 6 | 'while for foreach times in case when match with break continue ' + 7 | 'augment augmentation each find filter reduce ' + 8 | 'if then else otherwise try catch finally raise throw orIfNull ' + 9 | 'DynamicObject|10 DynamicVariable struct Observable map set vector list array', 10 | literal: 11 | 'true false null' 12 | }, 13 | contains: [ 14 | hljs.HASH_COMMENT_MODE, 15 | hljs.QUOTE_STRING_MODE, 16 | hljs.C_NUMBER_MODE, 17 | { 18 | className: 'meta', begin: '@[A-Za-z]+' 19 | } 20 | ] 21 | } 22 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/ldif.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | contains: [ 4 | { 5 | className: 'attribute', 6 | begin: '^dn', end: ': ', excludeEnd: true, 7 | starts: {end: '$', relevance: 0}, 8 | relevance: 10 9 | }, 10 | { 11 | className: 'attribute', 12 | begin: '^\\w', end: ': ', excludeEnd: true, 13 | starts: {end: '$', relevance: 0} 14 | }, 15 | { 16 | className: 'literal', 17 | begin: '^-', end: '$' 18 | }, 19 | hljs.HASH_COMMENT_MODE 20 | ] 21 | }; 22 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/mojolicious.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | subLanguage: 'xml', 4 | contains: [ 5 | { 6 | className: 'meta', 7 | begin: '^__(END|DATA)__$' 8 | }, 9 | // mojolicious line 10 | { 11 | begin: "^\\s*%{1,2}={0,2}", end: '$', 12 | subLanguage: 'perl' 13 | }, 14 | // mojolicious block 15 | { 16 | begin: "<%{1,2}={0,2}", 17 | end: "={0,1}%>", 18 | subLanguage: 'perl', 19 | excludeBegin: true, 20 | excludeEnd: true 21 | } 22 | ] 23 | }; 24 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/plaintext.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | disableAutodetect: true 4 | }; 5 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/profile.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | contains: [ 4 | hljs.C_NUMBER_MODE, 5 | { 6 | begin: '[a-zA-Z_][\\da-zA-Z_]+\\.[\\da-zA-Z_]{1,3}', end: ':', 7 | excludeEnd: true 8 | }, 9 | { 10 | begin: '(ncalls|tottime|cumtime)', end: '$', 11 | keywords: 'ncalls tottime|10 cumtime|10 filename', 12 | relevance: 10 13 | }, 14 | { 15 | begin: 'function calls', end: '$', 16 | contains: [hljs.C_NUMBER_MODE], 17 | relevance: 10 18 | }, 19 | hljs.APOS_STRING_MODE, 20 | hljs.QUOTE_STRING_MODE, 21 | { 22 | className: 'string', 23 | begin: '\\(', end: '\\)$', 24 | excludeBegin: true, excludeEnd: true, 25 | relevance: 0 26 | } 27 | ] 28 | }; 29 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/shell.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | aliases: ['console'], 4 | contains: [ 5 | { 6 | className: 'meta', 7 | begin: '^\\s{0,3}[\\w\\d\\[\\]()@-]*[>%$#]', 8 | starts: { 9 | end: '$', subLanguage: 'bash' 10 | } 11 | } 12 | ] 13 | } 14 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/taggerscript.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | 3 | var COMMENT = { 4 | className: 'comment', 5 | begin: /\$noop\(/, 6 | end: /\)/, 7 | contains: [{ 8 | begin: /\(/, 9 | end: /\)/, 10 | contains: ['self', { 11 | begin: /\\./ 12 | }] 13 | }], 14 | relevance: 10 15 | }; 16 | 17 | var FUNCTION = { 18 | className: 'keyword', 19 | begin: /\$(?!noop)[a-zA-Z][_a-zA-Z0-9]*/, 20 | end: /\(/, 21 | excludeEnd: true 22 | }; 23 | 24 | var VARIABLE = { 25 | className: 'variable', 26 | begin: /%[_a-zA-Z0-9:]*/, 27 | end: '%' 28 | }; 29 | 30 | var ESCAPE_SEQUENCE = { 31 | className: 'symbol', 32 | begin: /\\./ 33 | }; 34 | 35 | return { 36 | contains: [ 37 | COMMENT, 38 | FUNCTION, 39 | VARIABLE, 40 | ESCAPE_SEQUENCE 41 | ] 42 | }; 43 | }; -------------------------------------------------------------------------------- /packages/b-ber-markdown-renderer/src/highlightjs/languages/vbscript-html.js: -------------------------------------------------------------------------------- 1 | module.exports = function(hljs) { 2 | return { 3 | subLanguage: 'xml', 4 | contains: [ 5 | { 6 | begin: '<%', end: '%>', 7 | subLanguage: 'vbscript' 8 | } 9 | ] 10 | }; 11 | }; -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-parser-dialogue` 2 | 3 | The `b-ber-parser-dialogue` package is used internally parse the `dialogue` custom Markdown extension (directive). More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-parser-dialogue 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-parser-dialogue', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-dialogue/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-parser-dialogue', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-parser-figure` 2 | 3 | The `b-ber-parser-figure` package is used internally parse the `figure` custom Markdown extension (directive). More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-parser-figure 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-parser-figure', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-figure/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-parser-figure', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-parser-footnotes` 2 | 3 | The `b-ber-parser-footnotes` package is used internally parse footnotes in Markdown. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-parser-footnotes 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-parser-footnotes', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-footnotes/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-parser-footnotes', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-parser-gallery` 2 | 3 | The `b-ber-parser-gallery` package is used internally parse the `gallery` custom Markdown extension (directive). More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-parser-gallery 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-parser-gallery', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-gallery/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-parser-gallery', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-parser-section` 2 | 3 | The `b-ber-parser-section` package is used internally parse containing custom Markdown extension (directive). More information about b-ber directives can be found in the [All directives](https://github.com/triplecanopy/b-ber/wiki/all-directives) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-parser-section 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-parser-section', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-parser-section/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-parser-section', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.browserslistrc: -------------------------------------------------------------------------------- 1 | last 2 versions 2 | > 2% 3 | not dead -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.eslintignore: -------------------------------------------------------------------------------- 1 | index.d.ts -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | epub/* 3 | !epub/.keep 4 | dist 5 | node_modules 6 | npm-debug.log* 7 | yarn-debug.log* 8 | 9 | webpack/* 10 | !webpack/common.js 11 | !webpack/loaders.js 12 | !webpack/plugins.js 13 | !webpack/config.development.js 14 | !webpack/config.production.js 15 | !webpack/config.custom-example.js 16 | 17 | dev/* 18 | !dev/index.ejs 19 | !dev/index.example.js 20 | .env* 21 | 22 | /*.tgz 23 | /tmp 24 | /stats.json -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | package-lock=false 3 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/.prettierignore: -------------------------------------------------------------------------------- 1 | src/constants/index.js -------------------------------------------------------------------------------- /packages/b-ber-reader-react/__tests__/components/__snapshots__/Audio.test.jsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Audio renders the component 1`] = ` 4 |
5 |
11 | `; 12 | 13 | exports[`Audio renders the component 2`] = ` 14 |
15 |
20 | `; 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/__tests__/components/__snapshots__/Library.test.jsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Library renders the component 1`] = ` 4 |
5 |
6 |
10 |
11 | `; 12 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/__tests__/components/__snapshots__/Spinner.test.jsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Spinner renders the component 1`] = ` 4 |
5 |
8 |
11 |
12 |
13 | `; 14 | 15 | exports[`Spinner renders the component 2`] = ` 16 |
17 |
20 |
23 |
24 |
25 | `; 26 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/__tests__/components/__snapshots__/Video.test.jsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`Video renders the component 1`] = ` 4 |
5 |
11 | `; 12 | 13 | exports[`Video renders the component 2`] = ` 14 |
15 |
20 | `; 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/__tests__/models/GuideItem.test.js: -------------------------------------------------------------------------------- 1 | import GuideItem from '../../src/models/GuideItem' 2 | 3 | describe('GuideItem', () => { 4 | test('creates a guide item', () => { 5 | const data = { type: 'a', title: 'b', href: 'c' } 6 | const guideItem = new GuideItem(data) 7 | expect(guideItem).toEqual( 8 | expect.objectContaining({ 9 | type: expect.any(String), 10 | title: expect.any(String), 11 | href: expect.any(String), 12 | absoluteURL: expect.any(String), 13 | }) 14 | ) 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/dev/index.example.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | import Reader from '../src' 4 | 5 | function App() { 6 | return 7 | } 8 | 9 | const root = createRoot(document.getElementById('root')) 10 | root.render() 11 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-reader-react', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testEnvironment: 'jest-environment-jsdom-global', 6 | testURL: 'http://localhost/', 7 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/scripts/analyze.sh: -------------------------------------------------------------------------------- 1 | npm run clean 2 | NODE_ENV=production webpack --config webpack/config.production.js --progress --profile --color --profile --json > stats.json 3 | npm run webpack-bundle-analyzer stats.json -------------------------------------------------------------------------------- /packages/b-ber-reader-react/scripts/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Script accepts parameters for a custom Webpack config file. Defaults to 4 | # webpack/config.production.js 5 | # 6 | # 7 | # Examples: 8 | # 9 | # npm build 10 | # 11 | # npm build webpack/config.custom.js 12 | # 13 | 14 | npm run webpack:dist "$1" -------------------------------------------------------------------------------- /packages/b-ber-reader-react/scripts/start.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Script accepts parameters for a custom Webpack config file. Defaults to 4 | # webpack/config.development.js 5 | # 6 | # 7 | # Examples: 8 | # 9 | # npm start 10 | # 11 | # npm start webpack/config.custom.js 12 | # 13 | 14 | npm run watch "$1" -------------------------------------------------------------------------------- /packages/b-ber-reader-react/scripts/watch.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Script accepts parameters for a custom Webpack config file. Defaults to 4 | # webpack/config.production.js 5 | # 6 | # 7 | # Examples: 8 | # 9 | # npm watch 10 | # 11 | # npm watch webpack/config.custom.js 12 | # 13 | 14 | CONFIG=$([[ -z $1 ]] && echo "webpack/config.development.js" || echo "$1") 15 | 16 | npm run clean 17 | NODE_ENV=development webpack serve --config "$CONFIG" -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/actions/markers.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | import * as actionTypes from '../constants/markers' 3 | 4 | export const update = data => ({ 5 | type: actionTypes.UPDATE, 6 | payload: data, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/actions/reader-settings.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | import * as actionTypes from '../constants/reader-settings' 3 | 4 | export const updateSettings = data => ({ 5 | type: actionTypes.SETTINGS_UPDATE, 6 | payload: data, 7 | }) 8 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/actions/view.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | import * as actionTypes from '../constants/view' 3 | 4 | export const load = () => ({ 5 | type: actionTypes.LOAD, 6 | payload: true, 7 | }) 8 | 9 | export const unload = () => ({ 10 | type: actionTypes.UNLOAD, 11 | payload: false, 12 | }) 13 | 14 | export const updateUltimateNodePosition = position => ({ 15 | type: actionTypes.UPDATE_ULTIMATE_NODE_POSITION, 16 | payload: position, 17 | }) 18 | 19 | export const updateLastSpreadIndex = index => ({ 20 | type: actionTypes.UPDATE_LAST_SPREAD_INDEX, 21 | payload: index, 22 | }) 23 | 24 | export const queueDeferredCallbacks = () => ({ 25 | type: actionTypes.QUEUE_DEFERRED_CALLBACKS, 26 | payload: true, 27 | }) 28 | 29 | export const dequeueDeferredCallbacks = () => ({ 30 | type: actionTypes.DEQUEUE_DEFERRED_CALLBACKS, 31 | payload: false, 32 | }) 33 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Library.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const Library = props => ( 4 |
5 | {props.books.map((book, i) => ( 6 | 21 | ))} 22 |
23 | ) 24 | 25 | export default Library 26 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Audio.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Media from './Media' 3 | import AudioElement from './AudioElement' 4 | 5 | const Audio = props => ( 6 | 7 | ) 8 | 9 | export default Audio 10 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/AudioElement.jsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable jsx-a11y/media-has-caption*/ 2 | 3 | import React from 'react' 4 | 5 | const AudioElement = ({ 6 | elementKey, 7 | elementRef, 8 | handleLoad, 9 | handleEnded, 10 | controls, 11 | children, 12 | ...mediaAttributes 13 | }) => ( 14 | 24 | ) 25 | 26 | export default AudioElement 27 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/AudioControls.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import AudioControlsSimple from './AudioControlsSimple' 3 | import AudioControlsNormal from './AudioControlsNormal' 4 | import AudioControlsFull from './AudioControlsFull' 5 | 6 | const AudioControls = ({ config, ...rest }) => { 7 | if (config === 'simple') return 8 | if (config === 'normal') return 9 | return 10 | } 11 | 12 | export default AudioControls 13 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/AudioControlsSimple.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import MediaTime from './MediaTime' 3 | import MediaButtonPlayPause from './MediaButtonPlayPause' 4 | import MediaRangeSlider from './MediaRangeSlider' 5 | 6 | const AudioControlsSimple = props => ( 7 | <> 8 | 13 | 14 | 19 | 20 | 21 | ) 22 | 23 | export default AudioControlsSimple 24 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/AudioVideoControls.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import AudioControls from './AudioControls' 3 | import VideoControls from './VideoControls' 4 | 5 | const AudioVideoControls = ({ mediaType, ...rest }) => { 6 | if (mediaType === 'audio') 7 | return ( 8 | 14 | ) 15 | 16 | return ( 17 | 23 | ) 24 | } 25 | 26 | export default AudioVideoControls 27 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaButtonDownload.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const MediaButtonDownload = props => ( 4 | 9 | file_download 10 | 11 | ) 12 | 13 | export default MediaButtonDownload 14 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaButtonFullScreen.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | const MediaButtonFullScreen = props => ( 4 | 7 | ) 8 | 9 | export default MediaButtonFullScreen 10 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaButtonLoop.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import classNames from 'classnames' 3 | 4 | function MediaButtonLoop(props) { 5 | return ( 6 | 14 | ) 15 | } 16 | 17 | export default MediaButtonLoop 18 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaButtonPlayPause.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function MediaButtonPlayPause(props) { 4 | return props.paused ? ( 5 | 11 | ) : ( 12 | 18 | ) 19 | } 20 | 21 | export default MediaButtonPlayPause 22 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaButtonSeek.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function MediaButtonSeekForward(props) { 4 | return ( 5 | 11 | ) 12 | } 13 | 14 | function MediaButtonSeekBack(props) { 15 | return ( 16 | 22 | ) 23 | } 24 | 25 | export { MediaButtonSeekForward, MediaButtonSeekBack } 26 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaRangeSlider.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function MediaRangeSlider(props) { 4 | return ( 5 |
6 |
10 | 19 |
20 | ) 21 | } 22 | 23 | export default MediaRangeSlider 24 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/MediaTime.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | function MediaTime({ time }) { 4 | return
{time}
5 | } 6 | 7 | export default MediaTime 8 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/VideoControls.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import VideoControlsSimple from './VideoControlsSimple' 3 | import VideoControlsNormal from './VideoControlsNormal' 4 | import VideoControlsFull from './VideoControlsFull' 5 | 6 | const VideoControls = ({ config, ...rest }) => { 7 | if (config === 'simple') return 8 | if (config === 'normal') return 9 | return 10 | } 11 | 12 | export default VideoControls 13 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/VideoControlsFull.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import VideoControlsNormal from './VideoControlsNormal' 3 | import MediaButtonPlaybackRate from './MediaButtonPlaybackRate' 4 | 5 | const VideoControlsFull = props => ( 6 | <> 7 | 8 | 13 | 14 | ) 15 | 16 | export default VideoControlsFull 17 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/VideoControlsNormal.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import VideoControlsSimple from './VideoControlsSimple' 3 | import MediaTime from './MediaTime' 4 | import MediaButtonVolume from './MediaButtonVolume' 5 | import MediaButtonFullScreen from './MediaButtonFullScreen' 6 | 7 | const VideoControlsNormal = props => ( 8 | <> 9 | 10 | 14 | 18 | 19 | 20 | ) 21 | 22 | export default VideoControlsNormal 23 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Controls/VideoControlsSimple.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import MediaButtonPlayPause from './MediaButtonPlayPause' 3 | import MediaRangeSlider from './MediaRangeSlider' 4 | 5 | const VideoControlsSimple = props => ( 6 | <> 7 | 12 | 17 | 18 | ) 19 | 20 | export default VideoControlsSimple 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/Video.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import Media from './Media' 3 | import VideoElement from './VideoElement' 4 | 5 | const Video = props => ( 6 | 7 | ) 8 | 9 | export default Video 10 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/VideoElement.jsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable jsx-a11y/media-has-caption*/ 2 | 3 | import React from 'react' 4 | 5 | const VideoElement = ({ 6 | elementKey, 7 | elementRef, 8 | handleLoad, 9 | handleEnded, 10 | controls, 11 | children, 12 | ...mediaAttributes 13 | }) => ( 14 | 24 | ) 25 | 26 | export default VideoElement 27 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/VimeoPlayerControls.jsx: -------------------------------------------------------------------------------- 1 | // import React from 'react' 2 | 3 | // TODO this will implement/be replaced with Media/Controls components 4 | const VimeoPlayerControls = (/* 5 | { 6 | handleUpdatePlaying, 7 | handleUpdatePosition, 8 | handleUpdateVolume, 9 | } 10 | */) => 11 | null 12 | 13 | export default VimeoPlayerControls 14 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Media/VimeoPosterImage.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import classNames from 'classnames' 3 | 4 | function VimeoPosterImage({ src, playing, controls, handleUpdatePlaying }) { 5 | if (!src) return null 6 | 7 | return ( 8 | // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions 9 | 21 | ) 22 | } 23 | 24 | export default VimeoPosterImage 25 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Navigation/index.js: -------------------------------------------------------------------------------- 1 | export { default as NavigationHeader } from './NavigationHeader' 2 | export { default as NavigationFooter } from './NavigationFooter' 3 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Sidebar/index.js: -------------------------------------------------------------------------------- 1 | export { default as SidebarMetadata } from './SidebarMetadata' 2 | export { default as SidebarDownloads } from './SidebarDownloads' 3 | export { default as SidebarChapters } from './SidebarChapters' 4 | export { default as SidebarSettings } from './SidebarSettings' 5 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/Spinner.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import classNames from 'classnames' 3 | import { connect } from 'react-redux' 4 | 5 | function Spinner(props) { 6 | return ( 7 |
12 |
13 |
14 | ) 15 | } 16 | 17 | export default connect( 18 | ({ userInterface }) => ({ userInterface }), 19 | () => ({}) 20 | )(Spinner) 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/components/SpreadFigure.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import SpreadContext from '../lib/spread-context' 3 | 4 | const SpreadFigure = props => ( 5 | 6 | {({ left }) => { 7 | const { children, ...rest } = props 8 | 9 | return ( 10 |
11 | {children} 12 |
13 | ) 14 | }} 15 |
16 | ) 17 | 18 | export default SpreadFigure 19 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | debug: false, // Colorizes elements. Useful for work on spreads/markers 3 | showBreakoints: false, // Show breakpoints debugger 4 | showGrid: false, // Show grid overlay 5 | logTime: false, // Show console.time 6 | useLocalStorage: true, // Load/save data from localStorage 7 | verboseOutput: false, // Logging level 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/markers.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | export const UPDATE = 'UPDATE' 3 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/reader-location.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export const LOCATION_UPDATE = 'LOCATION_UPDATE' 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/reader-settings.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | 3 | export const SETTINGS_UPDATE = 'SETTINGS_UPDATE' 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/user-interface.js: -------------------------------------------------------------------------------- 1 | export const UPDATE = 'UPDATE' 2 | export const PAGE_TRANSITIONS_UPDATE = 'PAGE_TRANSITIONS_UPDATE' 3 | export const EVENT_HANDLING_UPDATE = 'EVENT_HANDLING_UPDATE' 4 | export const SPINNER_UPDATE = 'SPINNER_UPDATE' 5 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/view.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable import/prefer-default-export */ 2 | export const LOAD = 'LOAD' 3 | export const UNLOAD = 'UNLOAD' 4 | export const UPDATE_ULTIMATE_NODE_POSITION = 'UPDATE_ULTIMATE_NODE_POSITION' 5 | export const UPDATE_LAST_SPREAD_INDEX = 'UPDATE_LAST_SPREAD_INDEX' 6 | export const QUEUE_DEFERRED_CALLBACKS = 'QUEUE_DEFERRED_CALLBACKS' 7 | export const DEQUEUE_DEFERRED_CALLBACKS = 'DEQUEUE_DEFERRED_CALLBACKS' 8 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/constants/viewer-settings.js: -------------------------------------------------------------------------------- 1 | export const SETTINGS_LOAD = 'SETTINGS_LOAD' 2 | export const SETTINGS_SAVE = 'SETTINGS_SAVE' 3 | export const SETTINGS_UPDATE = 'SETTINGS_UPDATE' 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/fonts/CrimsonPro-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-reader-react/src/fonts/CrimsonPro-Light.ttf -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/fonts/CrimsonPro-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-reader-react/src/fonts/CrimsonPro-Medium.ttf -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/fonts/CrimsonPro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-reader-react/src/fonts/CrimsonPro-Regular.ttf -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/fonts/CrimsonPro-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-reader-react/src/fonts/CrimsonPro-SemiBold.ttf -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/helpers/Cache.js: -------------------------------------------------------------------------------- 1 | import Asset from './Asset' 2 | import Storage from './Storage' 3 | 4 | class Cache { 5 | static localStorageKey = 'bber_cache' 6 | 7 | static get(url) { 8 | const hash = Asset.createHash(url) 9 | const storage = Storage.get(Cache.localStorageKey) 10 | 11 | return storage && storage[hash] ? storage[hash] : null 12 | } 13 | 14 | static set(url, data) { 15 | const hash = Asset.createHash(url) 16 | const storage = Storage.get(Cache.localStorageKey) 17 | 18 | if (storage) { 19 | storage[hash] = { data } 20 | Storage.set(storage, Cache.localStorageKey) 21 | } 22 | } 23 | 24 | static clear() { 25 | Storage.clear(Cache.localStorageKey) 26 | } 27 | } 28 | 29 | export default Cache 30 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/helpers/DOM.js: -------------------------------------------------------------------------------- 1 | class DOM { 2 | static getPostionLeftFromMatrix(elem) { 3 | if (!elem || !elem.nodeType || elem.nodeType < 1) { 4 | console.warn( 5 | `DOM#getPostionLeftFromMatrix requires a valid DOM element; ${typeof elem} provided` 6 | ) 7 | return null 8 | } 9 | 10 | const matrix = window 11 | .getComputedStyle(elem) 12 | .transform.replace(/(matrix\(|\))/, '') 13 | .split(',') 14 | .map(a => Number(a.trim())) 15 | 16 | return matrix[4] 17 | } 18 | } 19 | 20 | export default DOM 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/helpers/Request.js: -------------------------------------------------------------------------------- 1 | import Url from './Url' 2 | 3 | class Request { 4 | static async get(requestUrl, type) { 5 | const resp = await fetch(requestUrl) 6 | const { ok, status, url } = resp 7 | 8 | const data = await resp[type]() 9 | 10 | return { data, request: { ok, status, url } } 11 | } 12 | 13 | static async getJson(requestUrl) { 14 | return Request.get(requestUrl, 'json') 15 | } 16 | 17 | static async getText(requestUrl) { 18 | return Request.get(requestUrl, 'text') 19 | } 20 | 21 | static getBooks(basePath = '') { 22 | const url = `${Url.stripTrailingSlash(basePath)}/api/books.json` 23 | return Request.getJson(url) 24 | } 25 | } 26 | 27 | export default Request 28 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/helpers/Types.js: -------------------------------------------------------------------------------- 1 | export const isNumeric = val => 2 | typeof val === 'number' && 3 | Number.isNaN(val) === false && 4 | Number.isFinite(val) === true 5 | export const isInt = val => isNumeric(val) && val % 1 === 0 6 | export const isFloat = val => isNumeric(val) && val % 1 !== 0 7 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/hooks/use-max-height.js: -------------------------------------------------------------------------------- 1 | import { useCallback, useState } from 'react' 2 | 3 | export default function useMaxHeight() { 4 | const defaultHeight = 0 5 | const [maxHeight, setMaxHeight] = useState(defaultHeight) 6 | 7 | const ref = useCallback( 8 | node => { 9 | if (node === null) { 10 | setMaxHeight(defaultHeight) 11 | return 12 | } 13 | 14 | const { y } = node.getBoundingClientRect() 15 | setMaxHeight(window.innerHeight - y) 16 | }, 17 | [window.innerHeight] 18 | ) 19 | 20 | return [ref, maxHeight] 21 | } 22 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { createStore, applyMiddleware, compose } from 'redux' 3 | import { Provider } from 'react-redux' 4 | import { thunk } from 'redux-thunk' 5 | import combinedReducers from './reducers' 6 | import { initialState as initialReaderSettings } from './reducers/reader-settings' 7 | import { mergeDeep } from './helpers/utils' 8 | import { App } from './components' 9 | 10 | import './lib/polyfills' 11 | 12 | const ConnectedApp = (props = {}) => { 13 | const store = createStore( 14 | combinedReducers, 15 | { readerSettings: mergeDeep(initialReaderSettings, props) }, 16 | compose(applyMiddleware(thunk)) 17 | ) 18 | 19 | return ( 20 | 21 | 22 | 23 | ) 24 | } 25 | 26 | export default ConnectedApp 27 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/index.scss: -------------------------------------------------------------------------------- 1 | @import 'styles/variables'; 2 | @import 'styles/mixins'; 3 | @import 'styles/fonts'; 4 | @import 'styles/icons'; 5 | @import 'styles/controls'; 6 | @import 'styles/spinner'; 7 | @import 'styles/print'; 8 | @import 'styles/media'; 9 | @import 'styles/footnote'; 10 | @import 'styles/layout'; 11 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/History.js: -------------------------------------------------------------------------------- 1 | import { createBrowserHistory } from 'history' 2 | 3 | const history = createBrowserHistory() 4 | export default history 5 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/browser.js: -------------------------------------------------------------------------------- 1 | import { detect } from 'detect-browser' 2 | 3 | const browser = detect() 4 | 5 | export default browser 6 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/polyfills.js: -------------------------------------------------------------------------------- 1 | import 'setimmediate' 2 | import 'object-fit-images' 3 | import 'url-search-params-polyfill' 4 | import './request-animation-frame' 5 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/reader-context.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { noop } from '../helpers/utils' 3 | 4 | const defaultContext = { 5 | lastSpread: false, 6 | spreadIndex: 0, 7 | getTranslateX: () => 0, 8 | navigateToChapterByURL: noop, 9 | getSpineItemByAbsoluteUrl: noop, 10 | } 11 | 12 | const ReaderContext = React.createContext(defaultContext) 13 | 14 | ReaderContext.displayName = 'ReaderContext' 15 | 16 | export default ReaderContext 17 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/spread-context.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | // Default value is currently only a single property for positioning figures in 4 | // spreads 5 | const defaultContext = { left: '0px', layout: 'columns' } 6 | const SpreadContext = React.createContext(defaultContext) 7 | 8 | SpreadContext.displayName = 'SpreadContext' 9 | 10 | export default SpreadContext 11 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/lib/transition-styles.js: -------------------------------------------------------------------------------- 1 | import { transitions } from '../constants' 2 | 3 | const styles = ({ transitionSpeed }) => ({ 4 | [transitions.SLIDE]: { transition: `transform ${transitionSpeed}ms ease` }, 5 | [transitions.FADE]: {}, 6 | }) 7 | 8 | export default styles 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/BookMetadata.js: -------------------------------------------------------------------------------- 1 | class BookMetadata { 2 | constructor({ 3 | title, 4 | creator, 5 | date, 6 | publisher, 7 | description, 8 | language, 9 | rights, 10 | identifier, 11 | }) { 12 | this.title = title 13 | this.creator = creator 14 | this.date = date 15 | this.publisher = publisher 16 | this.description = description 17 | this.language = language 18 | this.rights = rights 19 | this.identifier = identifier 20 | } 21 | 22 | set(key, val) { 23 | this[key] = val 24 | } 25 | 26 | get(key) { 27 | return this[key] 28 | } 29 | } 30 | 31 | export default BookMetadata 32 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/DeferredEvent.js: -------------------------------------------------------------------------------- 1 | import { messagesTypes } from '../constants' 2 | 3 | export default class DeferredEvent { 4 | constructor() { 5 | this.origin = window.location.origin 6 | this.type = messagesTypes.DEFERRED_EVENT 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/GuideItem.js: -------------------------------------------------------------------------------- 1 | class GuideItem { 2 | constructor({ type, title, href }) { 3 | this.type = type 4 | this.title = title 5 | this.href = href 6 | this.absoluteURL = '' 7 | } 8 | } 9 | 10 | export default GuideItem 11 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/MediaStyleSheet.js: -------------------------------------------------------------------------------- 1 | import { rand } from '../helpers/utils' 2 | 3 | class MediaStyleSheet { 4 | constructor({ id, media, styles }) { 5 | this.id = id || `_${rand()}` 6 | this.media = media 7 | this.styles = styles 8 | this.node = null 9 | } 10 | 11 | writeCss(doc) { 12 | const css = doc.createTextNode(this.styles) 13 | 14 | this.node.appendChild(css) 15 | } 16 | 17 | appendSheet(doc) { 18 | this.node = doc.createElement('style') 19 | 20 | this.node.setAttribute('id', this.id) 21 | this.node.setAttribute('media', this.media) 22 | this.node.appendChild(doc.createTextNode('')) // WebKit 23 | 24 | this.writeCss(doc) 25 | 26 | doc.body.appendChild(this.node) 27 | } 28 | 29 | removeSheet(doc) { 30 | doc.body.removeChild(this.node) 31 | } 32 | } 33 | 34 | export default MediaStyleSheet 35 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/PageEvent.js: -------------------------------------------------------------------------------- 1 | import { messagesTypes } from '../constants' 2 | 3 | export default class PageEvent { 4 | constructor({ 5 | spreadIndex, 6 | lastSpreadIndex, 7 | firstChapter, 8 | lastChapter, 9 | firstSpread, 10 | lastSpread, 11 | spreadDelta, 12 | }) { 13 | this.origin = window.location.origin 14 | this.type = messagesTypes.PAGINATION_EVENT 15 | this.spreadIndex = spreadIndex 16 | this.lastSpreadIndex = lastSpreadIndex 17 | this.firstChapter = firstChapter 18 | this.lastChapter = lastChapter 19 | this.firstSpread = firstSpread 20 | this.lastSpread = lastSpread 21 | this.spreadDelta = spreadDelta 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/SpineItem.js: -------------------------------------------------------------------------------- 1 | class SpineItem { 2 | constructor({ 3 | id, 4 | href, 5 | mediaType, 6 | properties, 7 | idref, 8 | linear, 9 | absoluteURL = '', 10 | title = '', 11 | slug = '', 12 | depth = 0, 13 | children = [], 14 | inTOC = false, 15 | }) { 16 | this.id = id 17 | this.href = href 18 | this.mediaType = mediaType 19 | this.properties = properties 20 | this.idref = idref 21 | this.linear = linear 22 | this.absoluteURL = absoluteURL 23 | this.title = title 24 | this.slug = slug 25 | this.depth = depth 26 | this.children = children 27 | this.inTOC = inTOC 28 | } 29 | 30 | set(key, val) { 31 | this[key] = val 32 | } 33 | 34 | get(key) { 35 | return this[key] 36 | } 37 | 38 | addChild(item) { 39 | this.children.push(item) 40 | } 41 | } 42 | 43 | export default SpineItem 44 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/models/index.js: -------------------------------------------------------------------------------- 1 | export { default as BookMetadata } from './BookMetadata' 2 | export { default as SpineItem } from './SpineItem' 3 | export { default as GuideItem } from './GuideItem' 4 | export { default as ViewerSettings } from './ViewerSettings' 5 | export { default as MediaStyleSheet } from './MediaStyleSheet' 6 | export { default as PageEvent } from './PageEvent' 7 | export { default as DeferredEvent } from './DeferredEvent' 8 | export { default as Script } from './Script' 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/reducers/index.js: -------------------------------------------------------------------------------- 1 | import { combineReducers } from 'redux' 2 | import readerSettings from './reader-settings' 3 | import viewerSettings from './viewer-settings' 4 | import readerLocation from './reader-location' 5 | import markers from './markers' 6 | import view from './view' 7 | import userInterface from './user-interface' 8 | 9 | const reducers = { 10 | readerSettings, 11 | viewerSettings, 12 | readerLocation, 13 | markers, 14 | view, 15 | userInterface, 16 | } 17 | 18 | const combinedReducers = combineReducers(reducers) 19 | 20 | export default combinedReducers 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/reducers/markers.js: -------------------------------------------------------------------------------- 1 | import * as actionTypes from '../constants/markers' 2 | 3 | const initialState = {} 4 | 5 | const updateMarker = (state, { markerId, ...nextState }) => ({ 6 | ...state, 7 | [markerId]: { 8 | ...(state[markerId] || {}), 9 | ...nextState, 10 | }, 11 | }) 12 | 13 | const markers = (state = initialState, action) => { 14 | switch (action.type) { 15 | case actionTypes.UPDATE: 16 | return updateMarker(state, action.payload) 17 | 18 | default: 19 | return state 20 | } 21 | } 22 | 23 | export default markers 24 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/reducers/reader-location.js: -------------------------------------------------------------------------------- 1 | import * as actionTypes from '../constants/reader-location' 2 | 3 | const defaultState = { 4 | searchParams: '', 5 | } 6 | 7 | const readerLocation = (state = defaultState, action = {}) => { 8 | switch (action.type) { 9 | case actionTypes.LOCATION_UPDATE: 10 | return { 11 | ...state, 12 | ...action.payload, 13 | } 14 | 15 | default: 16 | return state 17 | } 18 | } 19 | 20 | export default readerLocation 21 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/reducers/viewer-settings.js: -------------------------------------------------------------------------------- 1 | import * as actionTypes from '../constants/viewer-settings' 2 | import { ViewerSettings } from '../models' 3 | 4 | const settings = new ViewerSettings() 5 | const initialState = settings.get() 6 | 7 | const viewerSettings = (state = initialState, action = {}) => { 8 | switch (action.type) { 9 | case actionTypes.SETTINGS_UPDATE: 10 | case actionTypes.SETTINGS_SAVE: 11 | case actionTypes.SETTINGS_LOAD: 12 | return { ...state, ...action.payload } 13 | 14 | default: 15 | return state 16 | } 17 | } 18 | 19 | export default viewerSettings 20 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_fonts.scss: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'CrimsonPro'; 3 | font-style: normal; 4 | font-weight: 400; 5 | src: url('fonts/CrimsonPro-Regular.ttf') format('truetype'); 6 | } 7 | 8 | @font-face { 9 | font-family: 'CrimsonPro'; 10 | font-style: normal; 11 | font-weight: 600; 12 | src: url('fonts/CrimsonPro-SemiBold.ttf') format('truetype'); 13 | } 14 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_footnote.scss: -------------------------------------------------------------------------------- 1 | // TODO .bber-footnote__body 2 | .footnote__body { 3 | visibility: visible; 4 | display: block; 5 | background: $white; 6 | padding-left: 1.5em; 7 | padding-right: 1.5em; 8 | position: absolute; 9 | font-size: $font-size-serif; 10 | line-height: 1.6; 11 | z-index: 1000; 12 | 13 | &.footnote__body--hidden { 14 | visibility: hidden; 15 | } 16 | } 17 | 18 | // .footnote__content {} 19 | 20 | .footnote__content--count { 21 | padding-right: 10px; 22 | } 23 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_icons.scss: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Material Icons'; 3 | font-style: normal; 4 | font-weight: 400; 5 | font-display: block; 6 | src: url('~material-icons/iconfont/material-icons.woff2') format('woff2'), 7 | url('~material-icons/iconfont/material-icons.woff') format('woff'); 8 | } 9 | 10 | .material-icons { 11 | font-family: 'Material Icons'; 12 | font-weight: normal; 13 | font-style: normal; 14 | font-size: 24px; 15 | line-height: 1; 16 | letter-spacing: normal; 17 | text-transform: none; 18 | display: inline-block; 19 | white-space: nowrap; 20 | word-wrap: normal; 21 | direction: ltr; 22 | -webkit-font-smoothing: antialiased; 23 | -moz-osx-font-smoothing: grayscale; 24 | text-rendering: optimizeLegibility; 25 | font-feature-settings: 'liga'; 26 | } 27 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_layout.scss: -------------------------------------------------------------------------------- 1 | #layout { 2 | // Safari 3 | transform-style: preserve-3d; 4 | backface-visibility: hidden; 5 | } 6 | 7 | .bber-leaf { 8 | // Safari 9 | transform-style: preserve-3d; 10 | backface-visibility: hidden; 11 | 12 | position: fixed; 13 | top: 0; 14 | height: 100vh; 15 | z-index: 10; 16 | background-color: $white; 17 | 18 | &.bber-leaf--left { 19 | left: 0; 20 | } 21 | 22 | &.bber-leaf--right { 23 | right: 0; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_print.scss: -------------------------------------------------------------------------------- 1 | @media print { 2 | .bber-controls__header, 3 | .bber-controls__footer, 4 | .bber-leaf { 5 | display: none !important; 6 | } 7 | 8 | #frame { 9 | position: static !important; 10 | overflow: visible !important; 11 | } 12 | 13 | #layout { 14 | transform: none !important; 15 | height: auto !important; 16 | width: auto !important; 17 | columns: unset !important; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_spinner.scss: -------------------------------------------------------------------------------- 1 | @use 'sass:math'; 2 | 3 | // https://github.com/tobiasahlin/SpinKit/blob/master/examples/5-pulse.html 4 | @keyframes pulse { 5 | 0% { 6 | transform: scale(0); 7 | } 8 | 100% { 9 | transform: scale(1); 10 | opacity: 0; 11 | } 12 | } 13 | 14 | .bber-spinner { 15 | width: 100vw; 16 | height: 100vh; 17 | position: fixed; 18 | top: 0; 19 | left: 0; 20 | display: none; 21 | background: $white; 22 | } 23 | 24 | .bber-spinner--visible { 25 | display: block; 26 | } 27 | 28 | .bber-spinner__detail { 29 | position: absolute; 30 | top: calc(50% - #{math.div($spinner-size, 2)}); 31 | left: calc(50% - #{math.div($spinner-size, 2)}); 32 | width: $spinner-size; 33 | height: $spinner-size; 34 | margin: 0; 35 | padding: 0; 36 | background-color: $black; 37 | border-radius: 100%; 38 | animation: pulse 1s infinite ease-in-out; 39 | } 40 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/src/styles/_variables.scss: -------------------------------------------------------------------------------- 1 | // sass-lint:disable no-important,nesting-depth 2 | $white: rgba(255, 255, 255, 1); 3 | $black: #333333; 4 | $blue: rgba(105, 105, 252, 1); 5 | $violet: rgba(80, 80, 197, 1); 6 | $grey-light: rgba(211, 211, 211, 1); 7 | 8 | $small: 35px; 9 | $medium: 47px; 10 | 11 | $transition-speed-slow: 300ms; 12 | $transition-speed-normal: 200ms; 13 | $transition-speed-fast: 100ms; 14 | $transition-easing: ease; 15 | 16 | $anmiation-speed-normal: 250ms; 17 | $anmiation-speed-slow: 2500ms; 18 | 19 | $font-family-serif: CrimsonPro, Georgia, 'Iowan', Times, serif; 20 | $font-size-serif: 16px; 21 | 22 | $font-family-sans: Arial, Helvetica, sans-serif; 23 | $font-size-sans: 0.8rem; 24 | 25 | $spinner-size: 40px; 26 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/webpack/common.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | target: 'web', 5 | context: path.resolve(__dirname, '..', 'src'), 6 | devtool: process.env.NODE_ENV === 'production' ? false : 'source-map', 7 | output: { 8 | publicPath: '/', 9 | path: path.resolve(__dirname, '..', 'dist'), 10 | filename: data => 11 | /\.min/.test(data.chunk.name) ? '[name].[hash].js' : '[name].js', 12 | 13 | library: { 14 | root: 'BberReader', 15 | }, 16 | 17 | libraryTarget: 'umd', 18 | }, 19 | 20 | resolve: { 21 | extensions: ['.js', '.jsx'], 22 | fallback: { 23 | stream: require.resolve('stream-browserify'), // sax-js 24 | buffer: require.resolve('buffer'), // stream-browserify 25 | os: require.resolve('os-browserify/browser'), // detect-browser 26 | }, 27 | }, 28 | } 29 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/webpack/config.custom-example.js: -------------------------------------------------------------------------------- 1 | const { clone, setWith } = require('lodash') 2 | const prevConfig = require('./config.development') 3 | 4 | const nextConfig = setWith(clone(prevConfig), 'styles', './custom.scss', clone) 5 | 6 | module.exports = nextConfig 7 | -------------------------------------------------------------------------------- /packages/b-ber-reader-react/webpack/plugins.js: -------------------------------------------------------------------------------- 1 | const { DefinePlugin, NoEmitOnErrorsPlugin } = require('webpack') 2 | const MiniCssExtractPlugin = require('mini-css-extract-plugin') 3 | const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') 4 | const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts') 5 | 6 | const plugins = [ 7 | // Remove empty CSS files from the generated package and HTML 8 | new RemoveEmptyScriptsPlugin(), 9 | new DefinePlugin({ 10 | 'process.env': { 11 | NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development'), 12 | }, 13 | }), 14 | new NoEmitOnErrorsPlugin(), 15 | new MiniCssExtractPlugin({ filename: '[name].css' }), 16 | ] 17 | 18 | if (process.env.BUNDLE_ANALYZER) { 19 | plugins.push(new BundleAnalyzerPlugin()) 20 | } 21 | 22 | module.exports = plugins 23 | -------------------------------------------------------------------------------- /packages/b-ber-reader/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env", "@babel/preset-react"] 3 | } 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "react/destructuring-assignment": 0 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /packages/b-ber-reader/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-reader/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | dist 3 | epub/* 4 | !epub/.keep 5 | node_modules 6 | npm-debug.log* 7 | yarn-debug.log* 8 | 9 | /*.tgz -------------------------------------------------------------------------------- /packages/b-ber-reader/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | package-lock=false -------------------------------------------------------------------------------- /packages/b-ber-reader/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-reader` 2 | 3 | The `b-ber-reader` package is used to render a horizontally scrolling HTML view in a browser. It includes a user-interface to navigate through a published project, display a project metadata, and to download related project assets. This package contains the compiled source of the `@canopycanopycanopy/b-ber-reader-react` package. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-reader 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-reader/epub/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-reader/epub/.keep -------------------------------------------------------------------------------- /packages/b-ber-reader/index.js: -------------------------------------------------------------------------------- 1 | module.exports = {} 2 | -------------------------------------------------------------------------------- /packages/b-ber-reader/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-reader/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-reader', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testEnvironment: 'jest-environment-jsdom-global', 6 | testURL: 'http://localhost/', 7 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-reader/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import { createRoot } from 'react-dom/client' 3 | import Reader from '@canopycanopycanopy/b-ber-reader-react' 4 | import '@canopycanopycanopy/b-ber-reader-react/dist/styles.css' 5 | 6 | const root = createRoot(document.getElementById('root')) 7 | // eslint-disable-next-line react/jsx-props-no-spreading 8 | root.render() 9 | -------------------------------------------------------------------------------- /packages/b-ber-resources/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-resources/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | /index.js 5 | -------------------------------------------------------------------------------- /packages/b-ber-resources/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-resources/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-resources` 2 | 3 | The `b-ber-resources` package contains assets for newly initialized b-ber projects. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-resources 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-resources/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | describe('b-ber-resources', () => { 2 | test.todo('Requires tests') 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-resources/b-ber-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-resources/b-ber-logo.png -------------------------------------------------------------------------------- /packages/b-ber-resources/default-publishers-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-resources/default-publishers-logo.png -------------------------------------------------------------------------------- /packages/b-ber-resources/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-resources/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-resources', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-resources/src/index.js: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import fs from 'fs-extra' 3 | 4 | // Returns directory listings as {fileName: absoluteFilePath} 5 | export default () => 6 | fs.readdir(path.join(__dirname)).then(data => { 7 | const assets = {} 8 | data 9 | .filter(a => /png|jpe?g/.test(path.extname(a))) 10 | .map( 11 | a => 12 | (assets[path.basename(a, path.extname(a))] = path.join(__dirname, a)) 13 | ) 14 | 15 | return assets 16 | }) 17 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | /index.js 5 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-shapes-directives` 2 | 3 | The `b-ber-shapes-directives` package contains hashes of custom attributes and is used internally in rendering Markdown into HTML. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-shapes-directives 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-directives/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-shapes-directives', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | /dc 5 | /index.js 6 | /terms.js 7 | /elements.js 8 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-shapes-dublin-core` 2 | 3 | The `b-ber-shapes-dublin-core` package contains lists of [Dublin Core](https://www.dublincore.org) terms and elements. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-shapes-dublin-core 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | import { elements, terms } from '../src' 2 | 3 | describe('dublin-core', () => { 4 | it('exports the module', () => { 5 | expect(elements).toBeArray() 6 | expect(terms).toBeArray() 7 | }) 8 | }) 9 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-shapes-dublin-core', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/src/elements.js: -------------------------------------------------------------------------------- 1 | export default [ 2 | 'contributor', 3 | 'coverage', 4 | 'creator', 5 | 'description', 6 | 'format', 7 | 'identifier', 8 | 'language', 9 | 'publisher', 10 | 'relation', 11 | 'rights', 12 | 'source', 13 | 'subject', 14 | 'title', 15 | 'type', 16 | ] 17 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-dublin-core/src/index.js: -------------------------------------------------------------------------------- 1 | export { default as terms } from './terms' 2 | export { default as elements } from './elements' 3 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | /sequences 5 | /create-build-sequence.js 6 | /index.js 7 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-shapes-sequences` 2 | 3 | The `b-ber-shapes-sequences` package contains sequential lists of tasks for each of b-ber's builds. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-shapes-sequences 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/__tests__/index.test.js: -------------------------------------------------------------------------------- 1 | import sequences, { build } from '../src/sequences' 2 | 3 | describe('sequences', () => { 4 | it('exports the build list', () => { 5 | expect(build).toBeArray() 6 | }) 7 | it('exports the lists of sequences', () => { 8 | expect(sequences.epub).toEqual([...build, 'epub']) 9 | expect(sequences.mobi).toEqual([...build, 'mobiCSS', 'mobi']) 10 | expect(sequences.pdf).toEqual([...build, 'pdf']) 11 | expect(sequences.web).toEqual([...build, 'web']) 12 | expect(sequences.sample).toEqual([...build, 'sample']) 13 | expect(sequences.reader).toEqual([...build, 'reader']) 14 | }) 15 | }) 16 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-shapes-sequences', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/src/create-build-sequence.js: -------------------------------------------------------------------------------- 1 | import sequences from './sequences' 2 | 3 | export default function createBuildSequence(desiredSequences) { 4 | // Set up an array of build types 5 | const builds = Object.keys(sequences) 6 | 7 | // Filter the desired builds 8 | const chosen = desiredSequences.filter(a => sequences[a]) 9 | 10 | // Get the task sequence 11 | const sequence = chosen.length < 1 ? builds : chosen 12 | 13 | return sequence 14 | } 15 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/src/index.js: -------------------------------------------------------------------------------- 1 | export { default as sequences } from './sequences' 2 | export { default as createBuildSequence } from './create-build-sequence' 3 | -------------------------------------------------------------------------------- /packages/b-ber-shapes-sequences/src/sequences/index.js: -------------------------------------------------------------------------------- 1 | export const build = [ 2 | 'clean', 3 | 'container', 4 | 'cover', 5 | 'sass', 6 | 'copy', 7 | 'scripts', 8 | 'render', 9 | 'loi', 10 | 'footnotes', 11 | 'inject', 12 | 'opf', 13 | ] 14 | 15 | const sequences = { 16 | epub: [...build, 'epub'], 17 | mobi: [...build, 'mobiCSS', 'mobi'], 18 | pdf: [...build, 'pdf'], 19 | web: [...build, 'web'], 20 | sample: [...build, 'sample'], 21 | reader: [...build, 'reader'], 22 | xml: [...build, 'xml'], 23 | } 24 | 25 | export default sequences 26 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | dist 5 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-tasks` 2 | 3 | The `b-ber-tasks` package contains modules used for b-ber's I/O operations. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-tasks 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/copy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # keep in sync with scripts in package.json 4 | declare -a browserFiles=( 5 | "src/web/search.js" 6 | "src/web/worker.js" 7 | "src/web/navigation.js" 8 | "src/web/event-handlers.js" 9 | ) 10 | 11 | declare -a nodeFiles=( 12 | "src/cover/freeuniversal-bold-webfont.ttf" 13 | ) 14 | 15 | for file in "${browserFiles[@]}" 16 | do 17 | out="${file/src/dist}" 18 | node_modules/.bin/uglifyjs $file -o $out 19 | done 20 | 21 | for file in "${nodeFiles[@]}" 22 | do 23 | out="${file/src/dist}" 24 | cp $file $out 25 | done 26 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-tasks', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/src/clean/index.js: -------------------------------------------------------------------------------- 1 | import path from 'path' 2 | import fs from 'fs-extra' 3 | import state from '@canopycanopycanopy/b-ber-lib/State' 4 | import log from '@canopycanopycanopy/b-ber-logger' 5 | 6 | // Remove an ebook's output directory and outdated builds 7 | const clean = () => { 8 | const projectRoot = path.dirname(state.distDir) 9 | const fileType = `.${state.build}` 10 | 11 | const promises = fs 12 | .readdirSync(projectRoot) 13 | .filter(a => path.extname(a) === fileType) 14 | .map(b => 15 | fs 16 | .remove(path.join(projectRoot, b)) 17 | .then(() => log.info('clean remove [%s]', b)) 18 | ) 19 | 20 | return Promise.all(promises).then(() => 21 | fs 22 | .remove(state.distDir) 23 | .then(() => log.info('clean remove [%s]', state.distDir)) 24 | ) 25 | } 26 | 27 | export default () => clean().catch(log.error) 28 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/src/cover/freeuniversal-bold-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-tasks/src/cover/freeuniversal-bold-webfont.ttf -------------------------------------------------------------------------------- /packages/b-ber-tasks/src/epub/index.js: -------------------------------------------------------------------------------- 1 | import zipper from 'epub-zipper' 2 | import log from '@canopycanopycanopy/b-ber-logger' 3 | import state from '@canopycanopycanopy/b-ber-lib/State' 4 | import { getBookMetadata } from '@canopycanopycanopy/b-ber-lib/utils' 5 | 6 | const epub = () => 7 | process.argv.includes('--no-compile') 8 | ? Promise.resolve() 9 | : zipper 10 | .create({ 11 | input: state.distDir, 12 | output: process.cwd(), 13 | clean: true, 14 | fileName: getBookMetadata('identifier', state), 15 | }) 16 | .catch(log.error) 17 | 18 | export default epub 19 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/src/opf/index.js: -------------------------------------------------------------------------------- 1 | import Opf from './Opf' 2 | import ManifestAndMetadata from './ManifestAndMetadata' 3 | import Navigation from './Navigation' 4 | 5 | const opf = Opf.createOpf 6 | export default opf 7 | 8 | export { Opf, ManifestAndMetadata, Navigation } 9 | -------------------------------------------------------------------------------- /packages/b-ber-tasks/src/sample/index.js: -------------------------------------------------------------------------------- 1 | const sample = () => Promise.resolve() 2 | export default sample 3 | -------------------------------------------------------------------------------- /packages/b-ber-templates/.editorconfig: -------------------------------------------------------------------------------- 1 | 2 | root=true 3 | 4 | [*] 5 | indent_style=space 6 | end_of_line=lf 7 | charset=utf-8 8 | indent_size=4 9 | trim_trailing_whitespace=true 10 | insert_final_newline=true 11 | 12 | [*.md] 13 | trim_trailing_whitespace=false 14 | -------------------------------------------------------------------------------- /packages/b-ber-templates/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-templates/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | 5 | /Ncx 6 | /Opf 7 | /Ops 8 | /Project 9 | /Toc 10 | /Xhtml 11 | /Xml 12 | /figures 13 | /index.js 14 | -------------------------------------------------------------------------------- /packages/b-ber-templates/.npmrc: -------------------------------------------------------------------------------- 1 | scope=canopycanopycanopy 2 | -------------------------------------------------------------------------------- /packages/b-ber-templates/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-templates` 2 | 3 | The `b-ber-templates` package contains templates for different types of content that b-ber outputs during I/O operations. 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-templates 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-templates/__tests__/Xml.test.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs-extra' 2 | import Xml from '../src/Xml' 3 | 4 | afterAll(() => fs.remove('_project')) 5 | 6 | describe('templates.Xml', () => { 7 | test('container matches the snapshot', () => { 8 | expect(Xml.container()).toMatchSnapshot() 9 | }) 10 | 11 | test('mimetype matches the snapshot', () => { 12 | expect(Xml.mimetype()).toMatchSnapshot() 13 | }) 14 | }) 15 | -------------------------------------------------------------------------------- /packages/b-ber-templates/__tests__/__snapshots__/Xml.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`templates.Xml container matches the snapshot 1`] = ` 4 | " 5 | 6 | 7 | 8 | 9 | 10 | " 11 | `; 12 | 13 | exports[`templates.Xml mimetype matches the snapshot 1`] = `"application/epub+zip"`; 14 | -------------------------------------------------------------------------------- /packages/b-ber-templates/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | module.exports = require('babel-jest').createTransformer({ 2 | rootMode: 'upward', 3 | }) 4 | -------------------------------------------------------------------------------- /packages/b-ber-templates/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-templates', 3 | verbose: false, 4 | setupFilesAfterEnv: ['jest-extended'], 5 | testURL: 'http://localhost/', 6 | transform: { '^.+\\.jsx?$': './jest-transform-upward.js' }, 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Opf/Pkg.js: -------------------------------------------------------------------------------- 1 | import File from 'vinyl' 2 | 3 | class Pkg { 4 | static body() { 5 | return new File({ 6 | path: 'pkg.body.tmpl', 7 | contents: Buffer.from(` 8 | 17 | {% body %} 18 | 19 | `), 20 | }) 21 | } 22 | } 23 | 24 | export default Pkg 25 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Opf/index.js: -------------------------------------------------------------------------------- 1 | export { default as Pkg } from './Pkg' 2 | export { default as Metadata } from './Metadata' 3 | export { default as Manifest } from './Manifest' 4 | export { default as Spine } from './Spine' 5 | export { default as Guide } from './Guide' 6 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Ops/index.js: -------------------------------------------------------------------------------- 1 | class Ops { 2 | static mimetype() { 3 | return 'application/epub+zip' 4 | } 5 | } 6 | 7 | export default Ops 8 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/README.md.js: -------------------------------------------------------------------------------- 1 | module.exports = `# %PROJECT_NAME% 2 | 3 | Created with [b-ber](https://github.com/triplecanopy/b-ber/) 4 | ` 5 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/gitignore.js: -------------------------------------------------------------------------------- 1 | module.exports = `.DS_Store 2 | .tmp 3 | 4 | *.map 5 | *.epub 6 | *.mobi 7 | *.pdf 8 | *.xml 9 | 10 | node_modules 11 | npm-debug.log* 12 | bber-debug.log* 13 | 14 | /project* 15 | ` 16 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/project-name-chapter-01.md.js: -------------------------------------------------------------------------------- 1 | module.exports = `--- 2 | title: Project Name Chapter One 3 | type: bodymatter 4 | --- 5 | 6 | ::: chapter:project-name_chapter-one 7 | 8 | # Chapter Title 9 | 10 | Chapter Contents 11 | 12 | ::: exit:project-name_chapter-one 13 | ` 14 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/project-name-colophon.md.js: -------------------------------------------------------------------------------- 1 | module.exports = `--- 2 | title: Project Name Colophon 3 | type: colophon 4 | --- 5 | 6 | ::: colophon:project-name-colophon 7 | 8 | *Project Title* by Author 9 | 10 | Published by Publisher, 2019 11 | 12 | ::: subchapter:credits 13 | 14 | © 2019 *Project Title*, by Author. Texts and images copyright the author, unless otherwise stated. 15 | 16 | ::: exit:credits 17 | 18 | ::: logo:publishers-logo source:default-publishers-logo.png 19 | 20 | Publisher 21 | 1234 Street 22 | City, State Zip 23 | Country 24 | 25 | ::: logo:b-ber-logo source:b-ber-logo.png 26 | 27 | *Project Title* is a DRM-free ebook that uses [b-ber](https://github.com/triplecanopy/b-ber), software designed and developed by [Triple Canopy](https://canopycanopycanopy.com). 28 | 29 | ::: exit:project-name-colophon 30 | ` 31 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/project-name-title-page.md.js: -------------------------------------------------------------------------------- 1 | module.exports = `--- 2 | title: Project Name Title Page 3 | type: titlepage 4 | --- 5 | 6 | ::: titlepage:project-name-title-page 7 | 8 | # Project Title by Author 9 | 10 | ::: exit:project-name-title-page 11 | ` 12 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Project/toc.yml.js: -------------------------------------------------------------------------------- 1 | module.exports = `# Table of Contents 2 | # "in_toc:false" removes the entry from the built-in navigation of the reader. 3 | # "linear:false" removes the entry from the project's contents. 4 | - toc: 5 | in_toc: false 6 | linear: false 7 | # Cover 8 | - cover: 9 | in_toc: false 10 | # Project Contents 11 | - project-name-title-page 12 | - project-name-chapter-01 13 | - project-name-colophon 14 | ` 15 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/Xml/index.js: -------------------------------------------------------------------------------- 1 | class Xml { 2 | static container() { 3 | return ` 4 | 5 | 6 | 7 | 8 | 9 | ` 10 | } 11 | static mimetype() { 12 | return 'application/epub+zip' 13 | } 14 | } 15 | 16 | export default Xml 17 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/figures/epub.js: -------------------------------------------------------------------------------- 1 | import { media, iframe, figure, unsupported } from './helpers' 2 | 3 | const epub = { 4 | portrait: data => figure({ data, ratioName: 'portrait' }), 5 | landscape: data => figure({ data, ratioName: 'landscape' }), 6 | 'portrait-high': data => figure({ data, ratioName: 'portrait-high' }), 7 | square: data => figure({ data, ratioName: 'square' }), 8 | audio: data => media({ ...data, applyInlineClasses: true }), 9 | video: data => media({ ...data, applyInlineClasses: true }), 10 | iframe: data => iframe({ ...data, applyInlineClasses: true }), 11 | vimeo: data => unsupported({ data, applyInlineClasses: true }), 12 | } 13 | 14 | export default epub 15 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/figures/mobi.js: -------------------------------------------------------------------------------- 1 | import { media, unsupported, figure } from './helpers' 2 | 3 | const mobi = { 4 | portrait: data => figure({ data, ratioName: 'portrait', linkImages: false }), 5 | landscape: data => 6 | figure({ data, ratioName: 'landscape', linkImages: false }), 7 | 'portrait-high': data => 8 | figure({ data, ratioName: 'portrait-high', linkImages: false }), 9 | square: data => figure({ data, ratioName: 'square', linkImages: false }), 10 | audio: data => media({ ...data, applyInlineClasses: true }), 11 | video: data => media({ ...data, applyInlineClasses: true }), 12 | iframe: data => unsupported({ data, applyInlineClasses: true }), 13 | vimeo: data => unsupported({ data, applyInlineClasses: true }), 14 | } 15 | 16 | export default mobi 17 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/figures/reader.js: -------------------------------------------------------------------------------- 1 | import { media, iframe, figure, vimeo } from './helpers' 2 | 3 | const reader = { 4 | landscape: data => 5 | figure({ data, ratioName: 'landscape', applyInlineClasses: true }), 6 | portrait: data => 7 | figure({ data, ratioName: 'portrait', applyInlineClasses: true }), 8 | 'portrait-high': data => 9 | figure({ data, ratioName: 'portrait-high', applyInlineClasses: true }), 10 | square: data => 11 | figure({ data, ratioName: 'square', applyInlineClasses: true }), 12 | audio: data => media({ ...data, applyInlineClasses: true }), 13 | video: data => media({ ...data, applyInlineClasses: true }), 14 | iframe: data => iframe({ ...data, applyInlineClasses: true }), 15 | vimeo: data => vimeo({ ...data, applyInlineClasses: true }), 16 | } 17 | 18 | export default reader 19 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/figures/web.js: -------------------------------------------------------------------------------- 1 | import { media, iframe, figure, vimeo } from './helpers' 2 | 3 | const web = { 4 | portrait: data => figure({ data, ratioName: 'portrait' }), 5 | landscape: data => figure({ data, ratioName: 'landscape' }), 6 | 'portrait-high': data => figure({ data, ratioName: 'portrait-high' }), 7 | square: data => figure({ data, ratioName: 'square' }), 8 | audio: data => media({ ...data, applyInlineClasses: true }), 9 | video: data => media({ ...data, applyInlineClasses: true }), 10 | iframe: data => iframe({ ...data, applyInlineClasses: true }), 11 | vimeo: data => vimeo({ ...data, applyInlineClasses: true }), 12 | } 13 | 14 | export default web 15 | -------------------------------------------------------------------------------- /packages/b-ber-templates/src/index.js: -------------------------------------------------------------------------------- 1 | import Ncx from './Ncx' 2 | import Opf from './Opf' 3 | import Ops from './Ops' 4 | import Project from './Project' 5 | import Toc from './Toc' 6 | import Xhtml from './Xhtml' 7 | import Xml from './Xml' 8 | 9 | export { Ncx, Opf, Ops, Project, Toc, Xhtml, Xml } 10 | -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | .sass-cache 5 | -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-theme-sans` 2 | 3 | The `b-ber-theme-sans` package contains a theme written in SCSS for styling projects. The styles maintain consistency in layout across each of b-ber's output formats. More information about b-ber themes can be found in the [Themes](https://github.com/triplecanopy/b-ber/wiki/Themes) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-theme-sans 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/fonts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-theme-sans/fonts/.keep -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-theme-sans/images/.keep -------------------------------------------------------------------------------- /packages/b-ber-theme-sans/index.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const npmPackage = require('./package.json') 3 | 4 | module.exports = { 5 | name: 'b-ber-theme-sans', 6 | entry: path.join(__dirname, 'application.scss'), 7 | fonts: [], 8 | images: [], 9 | npmPackage, 10 | } 11 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: '../../.eslintrc.js' } 2 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | npm-debug.log* 4 | .sass-cache 5 | *.css 6 | *.css.map -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/README.md: -------------------------------------------------------------------------------- 1 | # `@canopycanopycanopy/b-ber-theme-serif` 2 | 3 | The `b-ber-theme-serif` package contains a theme written in SCSS for styling projects. The styles maintain consistency in layout across each of b-ber's output formats. More information about b-ber themes can be found in the [Themes](https://github.com/triplecanopy/b-ber/wiki/Themes) page in the b-ber [Wiki](https://github.com/triplecanopy/b-ber/wiki). 4 | 5 | ## Install 6 | 7 | ``` 8 | $ npm i -g @canopycanopycanopy/b-ber-theme-serif 9 | ``` 10 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/fonts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-theme-serif/fonts/.keep -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/images/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/triplecanopy/b-ber/59963709eda1a8eb12dde95405f8f01086d12cc7/packages/b-ber-theme-serif/images/.keep -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs') 2 | const path = require('path') 3 | const npmPackage = require('./package.json') 4 | 5 | module.exports = { 6 | name: 'b-ber-theme-serif', 7 | entry: path.join(__dirname, 'application.scss'), 8 | fonts: (() => 9 | fs 10 | .readdirSync(path.join(__dirname, 'fonts')) 11 | .filter(file => /\.(otf|ttf|woff2?|eot)/i.test(path.extname(file))))(), 12 | images: (() => 13 | fs 14 | .readdirSync(path.join(__dirname, 'images')) 15 | .filter(file => /\.(jpe?g|png|gif)/i.test(path.extname(file))))(), 16 | npmPackage, 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/layout/_epub.scss: -------------------------------------------------------------------------------- 1 | @if $build == 'epub' { 2 | html { 3 | font-size: 62.5%; 4 | } 5 | 6 | body { 7 | font-family: $font-serif; 8 | } 9 | 10 | .frontmatter.titlepage { 11 | #title-page-spread { 12 | background: none; 13 | 14 | ul { 15 | @include type-settings(0); 16 | list-style: none; 17 | padding: 0; 18 | margin-bottom: two-ems(0); 19 | } 20 | 21 | #title-dek { 22 | h1, 23 | h2 { 24 | @include type-settings(18); 25 | @include variant-weight(300, 300); 26 | line-height: 0.9em; 27 | margin-bottom: 0; 28 | } 29 | 30 | p { 31 | margin-top: two-ems(0); 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/layout/_layout.scss: -------------------------------------------------------------------------------- 1 | hr { 2 | @include following-paragraph-not-indented; 3 | @include following-element-has-no-top-padding; 4 | width: 6%; 5 | background-color: $grey-1; 6 | padding: 0; 7 | margin: two-lines(0) auto; 8 | height: 1px; 9 | border: 0; 10 | } 11 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/layout/_print.scss: -------------------------------------------------------------------------------- 1 | @media print { 2 | section { 3 | page-break-after: always; 4 | 5 | section { 6 | page-break-after: avoid; 7 | } 8 | } 9 | 10 | // Headers and footers generated by html-pdf package don't seem to respect 11 | // CSS here, so they're added inline in pdf/index.es 12 | 13 | // .pdf__header, 14 | // .pdf__footer {} 15 | 16 | // .cover {} 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/layout/_table.scss: -------------------------------------------------------------------------------- 1 | @function table-border($width: 1px, $style: solid, $color: $grey-0) { 2 | @return $width $style $color; 3 | } 4 | 5 | table { 6 | font-size: 1em; 7 | page-break-inside: avoid; 8 | border-collapse: collapse; 9 | border-spacing: 0; 10 | width: 100%; 11 | margin: two-lines(0) 0; 12 | 13 | tr { 14 | font-size: 1em; 15 | 16 | th { 17 | @include text-small; 18 | border-top: table-border(); 19 | } 20 | 21 | th, 22 | td { 23 | @include text-small; 24 | @include padding('text-default', 1); 25 | text-align: left; 26 | 27 | border-left: table-border(); 28 | border-right: table-border(); 29 | border-bottom: table-border(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/layout/index.scss: -------------------------------------------------------------------------------- 1 | @import 'container'; 2 | @import 'figure'; 3 | @import 'layout'; 4 | @import 'list'; 5 | @import 'table'; 6 | @import 'text'; 7 | @import 'media-controls'; 8 | 9 | // Conditional styles 10 | @import 'web'; 11 | @import 'epub'; 12 | @import 'reader'; 13 | 14 | // For print views and PDF generation 15 | @import 'print'; 16 | 17 | @import 'helpers'; 18 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/typography/_fonts.scss: -------------------------------------------------------------------------------- 1 | .icon-font { 2 | font-weight: normal; 3 | font-style: normal; 4 | font-size: 24px; 5 | line-height: 1; 6 | letter-spacing: normal; 7 | text-transform: none; 8 | display: inline-block; 9 | white-space: nowrap; 10 | word-wrap: normal; 11 | // direction: ltr; // Breaks epub validation 12 | font-feature-settings: 'liga'; 13 | font-smooth: antialiased; 14 | -webkit-font-smoothing: antialiased; 15 | } 16 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/typography/_reset.scss: -------------------------------------------------------------------------------- 1 | h1, 2 | h2, 3 | h3, 4 | h4, 5 | h5, 6 | h6, 7 | p { 8 | margin: 0; 9 | padding: 0; 10 | } 11 | -------------------------------------------------------------------------------- /packages/b-ber-theme-serif/typography/index.scss: -------------------------------------------------------------------------------- 1 | @import 'fonts'; 2 | @import 'reset'; 3 | -------------------------------------------------------------------------------- /packages/b-ber-validator/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | settings: { 5 | 'import/resolver': { 6 | node: { 7 | extensions: ['.ts'], 8 | }, 9 | }, 10 | }, 11 | parserOptions: { 12 | ecmaVersion: 2020, 13 | sourceType: 'module', 14 | tsconfigRootDir: __dirname, 15 | project: ['./tsconfig.eslint.json'], 16 | createDefaultProgram: true, 17 | }, 18 | extends: [ 19 | 'plugin:@typescript-eslint/recommended', 20 | 'plugin:prettier/recommended', 21 | ], 22 | rules: { 23 | '@typescript-eslint/no-explicit-any': 0, 24 | '@typescript-eslint/explicit-module-boundary-types': 0, 25 | }, 26 | } 27 | -------------------------------------------------------------------------------- /packages/b-ber-validator/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | -------------------------------------------------------------------------------- /packages/b-ber-validator/README.md: -------------------------------------------------------------------------------- 1 | # `b-ber-validator` 2 | 3 | > TODO: description 4 | 5 | ## Usage 6 | 7 | ``` 8 | const bBerValidator = require('b-ber-validator'); 9 | 10 | // TODO: DEMONSTRATE API 11 | ``` 12 | -------------------------------------------------------------------------------- /packages/b-ber-validator/jest-transform-upward.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/no-var-requires */ 2 | module.exports = require('babel-jest').createTransformer({ 3 | rootMode: 'upward', 4 | }) 5 | -------------------------------------------------------------------------------- /packages/b-ber-validator/jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | name: 'b-ber-validator', 3 | verbose: false, 4 | verbose: false, 5 | setupFilesAfterEnv: ['jest-extended'], 6 | testPathIgnorePatterns: ['__mocks__'], 7 | testURL: 'http://localhost/', 8 | moduleNameMapper: { 9 | '@canopycanopycanopy/b-ber-shapes-directives': 10 | '/../b-ber-shapes-directives', 11 | }, 12 | transform: { 13 | '^.+\\.jsx?$': './jest-transform-upward.js', 14 | '^.+\\.tsx?$': 'ts-jest', 15 | }, 16 | } 17 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/TODO.md: -------------------------------------------------------------------------------- 1 | - [x] Add error messages 2 | - [x] Add string output at error location 3 | - [x] Add list of allowed directive names 4 | - [x] Add support for inline directive followed by captions (i.e., `:: caption text`) 5 | - [ ] Gallery directives 6 | - [x] Dialogue directives 7 | - [x] Add tests 8 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/colors.ts: -------------------------------------------------------------------------------- 1 | const colors = { 2 | reset: '\x1b[0m%s', 3 | bright: '\x1b[1m%s', 4 | dim: '\x1b[2m%s', 5 | underscore: '\x1b[4m%s', 6 | blink: '\x1b[5m%s', 7 | reverse: '\x1b[7m%s', 8 | hidden: '\x1b[8m%s', 9 | 10 | fgblack: '\x1b[30m%s', 11 | fgred: '\x1b[31m%s', 12 | fggreen: '\x1b[32m%s', 13 | fgyellow: '\x1b[33m%s', 14 | fgblue: '\x1b[34m%s', 15 | fgmagenta: '\x1b[35m%s', 16 | fgcyan: '\x1b[36m%s', 17 | fgwhite: '\x1b[37m%s', 18 | 19 | bgblack: '\x1b[40m%s', 20 | bgred: '\x1b[41m%s', 21 | bggreen: '\x1b[42m%s', 22 | bgyellow: '\x1b[43m%s', 23 | bgblue: '\x1b[44m%s', 24 | bgmagenta: '\x1b[45m%s', 25 | bgcyan: '\x1b[46m%s', 26 | bgwhite: '\x1b[47m%s', 27 | } 28 | 29 | export default colors 30 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/constrained.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser } from 'b-ber-validator' 2 | 3 | // Value *must* match first parser, and can match second 4 | export const constrained = ( 5 | parser1: Parser, 6 | parser2: Parser, 7 | expected = 'Valid constraint' 8 | ) => { 9 | return (ctx: Context) => { 10 | const res1 = parser1(ctx) 11 | const res2 = parser2(ctx) 12 | 13 | // Fails fatally if first condition is not met 14 | if (!res1.success) { 15 | return { ...res1, expected, fatal: true } 16 | } 17 | 18 | // Allowed to fail normally afterwards 19 | return res2 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/eol.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | import { failure } from '../lib/failure' 3 | import { success } from '../lib/success' 4 | 5 | // eol function doesn't advance index 6 | 7 | class EOL {} 8 | 9 | export function eol() { 10 | return (ctx: Context) => { 11 | const match = '\n' 12 | const endIdx = ctx.index + match.length 13 | if ( 14 | ctx.index === ctx.text.length || 15 | ctx.text.substring(ctx.index, endIdx) === match 16 | ) { 17 | return success(ctx, new EOL()) 18 | } 19 | 20 | return failure(ctx, 'End of line', true) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/eos.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | import { failure } from '../lib/failure' 3 | import { success } from '../lib/success' 4 | 5 | class EOS {} 6 | 7 | export function eos() { 8 | return (ctx: Context) => 9 | ctx.index === ctx.text.length 10 | ? success(ctx, new EOS()) 11 | : failure(ctx, 'End of string') 12 | } 13 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/lazy.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser } from 'b-ber-validator' 2 | 3 | export function lazy(parserFn: () => Parser) { 4 | return (ctx: Context) => parserFn()(ctx) 5 | } 6 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/many.ts: -------------------------------------------------------------------------------- 1 | import { Context, Failure, Parser, Success } from 'b-ber-validator' 2 | import { success } from '../lib/success' 3 | 4 | // Look for 0 or more of something, until we can't parse any more. 5 | // Note that this function never fails, it will instead succeed 6 | // with an empty array. 7 | 8 | export function many(parser: Parser) { 9 | return (ctx: Context) => { 10 | const values = [] 11 | let nextCtx = ctx 12 | while (true) { 13 | const res = parser(nextCtx) 14 | if (!res.success) { 15 | if ((res as Failure).fatal) return res 16 | 17 | break 18 | } 19 | 20 | values.push((res as Success).value) 21 | nextCtx = res.ctx 22 | } 23 | 24 | return success(nextCtx, values) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/map.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser, Success } from 'b-ber-validator' 2 | import { success } from '../lib/success' 3 | 4 | // Convenience method that will map a Success to callback, to let us do 5 | // common things like build AST nodes from input strings. 6 | 7 | export function map(parser: Parser, fn: (value: any) => any) { 8 | return (ctx: Context) => { 9 | const res = parser(ctx) 10 | return res.success ? success(res.ctx, fn((res as Success).value)) : res 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/not.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser } from 'b-ber-validator' 2 | import { success } from '../lib/success' 3 | 4 | export function not(parser: Parser) { 5 | return (ctx: Context) => { 6 | const values: any[] = [] 7 | const nextCtx = { ...ctx } 8 | 9 | while (nextCtx.index < nextCtx.text.length) { 10 | const res = parser(nextCtx) 11 | 12 | if (res.success) return success(nextCtx, null) 13 | 14 | nextCtx.index += 1 15 | } 16 | 17 | return success(nextCtx, values) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/optional.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser } from 'b-ber-validator' 2 | import { success } from '../lib/success' 3 | import { oneOf } from './oneOf' 4 | 5 | // Match a parser, or succeed with null 6 | export function optional(parser: Parser) { 7 | return oneOf([parser, (ctx: Context) => success(ctx, null)]) 8 | } 9 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/regex.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | import { failure } from '../lib/failure' 3 | import { success } from '../lib/success' 4 | 5 | // Match a regexp or fail 6 | 7 | export function regex(re: RegExp, expected: string) { 8 | return (ctx: Context) => { 9 | re.lastIndex = ctx.index 10 | const res = re.exec(ctx.text) 11 | if (res && res.index === ctx.index) { 12 | return success({ ...ctx, index: ctx.index + res[0].length }, res[0]) 13 | } 14 | 15 | return failure(ctx, expected) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/required.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser } from 'b-ber-validator' 2 | 3 | // Returns fatal error to halt parser in case of failure 4 | export const required = (parser: Parser) => { 5 | return (ctx: Context) => { 6 | const res = parser(ctx) 7 | if (!res.success) return { ...res, fatal: true } 8 | return res 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/sequence.ts: -------------------------------------------------------------------------------- 1 | import { Context, Parser, Success } from 'b-ber-validator' 2 | import { success } from '../lib/success' 3 | 4 | // Look for an exact sequence of parsers, or fail 5 | 6 | export function sequence(parsers: Parser[]) { 7 | return (ctx: Context) => { 8 | const values = [] 9 | let nextCtx = ctx 10 | for (const parser of parsers) { 11 | const res = parser(nextCtx) 12 | if (!res.success) return res 13 | values.push((res as Success).value) 14 | nextCtx = res.ctx 15 | } 16 | return success(nextCtx, values) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/combinators/string.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | import { failure } from '../lib/failure' 3 | import { success } from '../lib/success' 4 | 5 | export function string(match: string, expected = '') { 6 | return (ctx: Context) => { 7 | const endIdx = ctx.index + match.length 8 | 9 | if (ctx.text.substring(ctx.index, endIdx) === match) { 10 | return success({ ...ctx, index: endIdx }, match) 11 | } 12 | 13 | return failure(ctx, expected || match) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/index.ts: -------------------------------------------------------------------------------- 1 | import validator from './validator' 2 | 3 | export { default as colors } from './colors' 4 | export { default as report } from './report' 5 | 6 | export default validator 7 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/lib/failure.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | 3 | export function failure(ctx: Context, expected: string, fatal = false) { 4 | return { success: false, expected, ctx, fatal } 5 | } 6 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/lib/flat.ts: -------------------------------------------------------------------------------- 1 | // Polyfill Array.flat for Node < 11 2 | 3 | export function flat(arr: any[], d = 1): any[] { 4 | if ('flat' in []) return arr.flat(d) 5 | 6 | return d > 0 7 | ? arr.reduce( 8 | (acc, val) => acc.concat(Array.isArray(val) ? flat(val, d - 1) : val), 9 | [] 10 | ) 11 | : arr.slice() 12 | } 13 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/lib/success.ts: -------------------------------------------------------------------------------- 1 | import { Context } from 'b-ber-validator' 2 | 3 | export function success(ctx: Context, value: any) { 4 | return { success: true, value, ctx } 5 | } 6 | -------------------------------------------------------------------------------- /packages/b-ber-validator/src/typings/b-ber-shapes-directives/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@canopycanopycanopy/b-ber-shapes-directives' { 2 | export const INLINE_DIRECTIVES: Set 3 | export const BLOCK_DIRECTIVES: Set 4 | export const MISC_DIRECTIVES: Set 5 | export const DRAFT_DIRECTIVES: Set 6 | export const DEPRECATED_DIRECTIVES: Set 7 | } 8 | -------------------------------------------------------------------------------- /packages/b-ber-validator/tsconfig.build.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "exclude": ["node_modules", "src/mocks.ts", "src/tests.ts"] 4 | } 5 | -------------------------------------------------------------------------------- /packages/b-ber-validator/tsconfig.eslint.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "include": [ 4 | "src/**/*.ts", 5 | "__mocks__/**/*.js", 6 | "__tests__/**/*.js", 7 | "jest.config.js", 8 | "jest-transform-upward.js" 9 | ], 10 | "exclude": ["node_modules"] 11 | } 12 | -------------------------------------------------------------------------------- /svgo.yml: -------------------------------------------------------------------------------- 1 | plugins: 2 | - addAttributesToSVGElement: 3 | attributes: 4 | - focusable: false 5 | - collapseGroups: true 6 | - removeDesc: true 7 | - removeScriptElement: true 8 | - removeStyleElement: true 9 | - removeTitle: false 10 | - removeUselessDefs: true 11 | - removeViewBox: false 12 | --------------------------------------------------------------------------------