Coder Social home page Coder Social logo

1sting / gitbook-plugin-sectionx-cn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kmizu/gitbook-plugin-div-element

0.0 1.0 0.0 45 KB

A GitBook plugin created for you to separate the page into sections, and add buttons to allow readers to control the visibility of each section

License: Apache License 2.0

CSS 5.82% JavaScript 94.18%

gitbook-plugin-sectionx-cn's Introduction

This is GitBook plugin created for you to separate the page into sections, and add buttons to allow readers to control the visibility of each section.

Example

You can see it here: Click here

Changelog

  • 3.1.0: Added custom tag support (thanks @cyrusn for the PR).
  • 3.0.0: Requires gitbook 3.0 or up, fixed plugin in gitbook 3.0.
  • 2.1.0: Added data-collapse option.
  • 2.0.1: Fixed CSS problem, upgraded to latest bootstrap and simplified code.

How to use section?

Defining new section

You can define a new section with the use of tag:

<!--sec data-title="Introduction" data-id="section0" data-show=true ces-->

Insert markdown content here (you should start with h3 if you use heading).

<!--endsec-->

A section will take three arguments, listed as follows:

  • data-title: the title of the section, it will appear as the title of the bootstrap panel (with size of h2).
    • Please note that you cannot use the character " in the title, please use &quot; instead.
  • data-id: the id of the section, it is useful for button control (discussed in next section).
  • data-show: a boolean value denoting by default, whether or not the panel content will be visible.
    • true: the panel content is visible to user by default, the panel title will be clickable.
    • false: the panel content is hidden to user by default, the panel title is not clickable and can only be viewed by adding a custom button (discussed in next section).
  • data-nopdf: a boolean value denoting whether or not the section will be hidden in pdf exports.
    • true: the panel will not be shown in .pdf or .epub.
  • data-collapse: a boolean value denoting whether the section will be opened (but still visible) by default.
    • true: the panel content is visible to user by default, but closed.
    • false: the panel content is visible to user by default, but opened (default settings).

Using a button to control section visibility

By adding inline HTML in the GitBook, the following code can add a button to allow you to view or hide other sections. Here are the explanation of each tags:

<button class="section" target="section1" show="Show next section" hide="Hide next section"></button>
  • class: the button has to belong to the class "section".
  • target: when pressed, the section with the id of target will be toggled.
  • show: the text on the button when the target section is hidden.
  • hide: the text on the button when the target section is visible.

Note that you can leave 'show' and 'hide' undefined, in this case, an up-arrow or down-arrow will be displayed instead. The button will not be outputed if exported to .pdf or other formats.

Using Custom Tag for section title

  • available HTML tag for section title h1, h2, h3, h4, h5, h6, b
{
	"pluginsConfig": {
	    "sectionx": {
	      "tag": "b"
	    }
	  }
}

gitbook-plugin-sectionx-cn's People

Contributors

isaacyiu0369 avatar 1sting avatar cyrusn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.