npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

markdown-query

v1.0.0

Published

A versatile library for querying, updating, and manipulating Markdown content in JavaScript/TypeScript applications.

Downloads

3

Readme

markdown-query

npm version npm License

markdown-query is a versatile library for querying, updating, and manipulating Markdown content in JavaScript/TypeScript applications. It provides a set of methods to perform common tasks such as retrieving elements by ID, class, or tag, updating content, and more.

Table of Contents

  1. Installation
  2. Usage
  3. API Reference
  4. Contributing
  5. License
  6. Author
  7. Contact

Installation

You can install markdown-query using npm, yarn, or pnpm. Choose your preferred package manager:

NPM

npm install markdown-query

Yarn

yarn add markdown-query

PNPM

pnpm add markdown-query

Usage

Basic Example

import { MarkdownQuery } from 'markdown-query';

const markdownQuery = new MarkdownQuery();

// Example: Get element content by ID
const markdownContent = `
  <div id="example">
    This is some content.
  </div>
`;

const elementContent = markdownQuery.getElementById(markdownContent, 'example');
console.log(elementContent); // Output: This is some content.



or directly use this like 

import { MarkdownQuery } from 'markdown-query';

const markdownContent = `
  <div id="example">
    This is some content.
  </div>
`;
const elementContent = markdownQuery.getElementById(markdownContent, 'example');
console.log(elementContent); // Output: This is some content.

Advanced Examples

Updating Content

// Update content of an element by ID
const updatedContentById = markdownQuery.updateElementById(markdownContent, 'example', 'Updated content.');
console.log(updatedContentById);

// Update alt text for an image
const imageUrl = 'https://example.com/image.jpg';
const updatedImageAlt = markdownQuery.updateMarkdownImageAlt(markdownContent, imageUrl, 'New Alt Text');
console.log(updatedImageAlt);

Deleting Content

// Delete an element by ID
const deletedContentById = markdownQuery.deleteElementById(markdownContent, 'example');
console.log(deletedContentById);

// Delete a link by URL
const linkUrl = 'https://example.com';
const deletedLink = markdownQuery.deleteMarkdownLink(markdownContent, linkUrl);
console.log(deletedLink);

API Reference

For detailed information on all available methods, parameters, and examples, please refer to the API Reference.

| Method | Description | | ----------------------------------- | ---------------------------------------------------------------------------------------------------- | | getElementById | Retrieves content for elements with the specified ID. Returns null if no element is found. | | getElementByClassName | Retrieves an array of contents for elements with the given class name. | | getElementsByTag | Retrieves an array of contents for elements with the specified tag name. | | getMarkdownLinks | Retrieves an array of links (text and URL) from the Markdown content. | | getMarkdownImages | Retrieves an array of images (alt text and URL) from the Markdown content. | | getMarkdownCodeBlocks | Retrieves an array of code blocks from the Markdown content. | | getMarkdownList | Retrieves an array of list items from the Markdown content. | | getMarkdownHeaders | Retrieves an array of headers from the Markdown content. | | getMarkdownCodeBlockByIndex | Extracts a specific code block based on the index. Returns null if the index is out of bounds. | | getMarkdownImageAlt | Retrieves the alt text for an image. Returns null if the image is not found or alt text is not available.| | updateElementById | Updates the content of an element by ID. Returns the updated Markdown content. | | updateElementByClassName | Updates the content of elements with the given class name. Returns the updated Markdown content. | | updateElementByTag | Updates the content of elements with the given tag name. Returns the updated Markdown content. | | updateMarkdownLink | Updates a link in the Markdown content. Returns the updated Markdown content. | | updateMarkdownImageAlt | Updates the alt text for an image. Returns the updated Markdown content. | | updateMarkdownHeaders | Updates the headers in the Markdown content. Returns the updated Markdown content. | | updateMarkdownList | Updates list items in the Markdown content. Returns the updated Markdown content. | | deleteElementById | Deletes the element with the specified ID. Returns Markdown content with the element removed. | | deleteElementByClassName | Deletes elements with the specified class name. Returns Markdown content with the elements removed. | | deleteElementByTag | Deletes elements with the specified tag name. Returns Markdown content with the elements removed. | | deleteMarkdownLink | Deletes a link with the specified URL. Returns Markdown content with the link removed. | | deleteMarkdownImage | Deletes an image with the specified URL. Returns Markdown content with the image removed. | | deleteMarkdownHeaders | Deletes headers with the specified text. Returns Markdown content with the headers removed. | | deleteMarkdownCodeBlockByIndex | Deletes a code block at the specified index. Returns Markdown content with the code block removed. | | deleteMarkdownImageAlt | Deletes the alt text for an image. Returns updated Markdown content. |

Contributing

We welcome contributions! Before contributing, please read our contribution guidelines and adhere to our Code of Conduct.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Shiv Kumar

Shiv Kumar

Contact

For any inquiries or questions, feel free to reach out at [email protected].