VuePress: How to modify the markdown content - vuepress

VuePress (v1) provides this API to access the page context: https://v1.vuepress.vuejs.org/plugin/option-api.html#extendpagedata
I can access these properties but I can't change the value of _content for instance.
I would like to modify (replace some regexp) the markdown before it get's rendered by Vue (an even before it's get parsed by the markdown parser).
Maybe it makes more sense to do it with a markdown-it plugin using the chainmarkdown API but I don't know how exactly. But the question is more how to write a plugin for markdown-it which can modify the content before even parsing, because I need the raw text.

Here is one markdown-it plugin that allows you to do exactly that by defining regular expressions: https://www.npmjs.com/package/markdown-it-regexp

Related

Python Sphinx Validate and update schema

I'm using Sphinx to maintain docs on a project, I am generating a jsonschema document from a tool where all properties of objects are listed.
Those objects properties are documented in rst files, I need to:
I've managed to read the rst files in the doctree-resolved event, and match with the json property, but I'm not sure if this is the best approach since I need
a) check all properties are documented, this is almost donde, I can mark on the json properties found and then check the json at the end.
b) Copy the description retrieved from the doctree object in the json (adding a property to the json) the format I need is markup, so I need to figure out how to convert a doctree node(set) to markup. Also the url links should be working at this stage. Also if markdown is not possible converting the fragment to html then to markdown might be easier
I don't know if I'm in the right path or should I write a builder instead?
Thanks

Gatsby & GraphQL: Transforming a String field into markdown

I have a GraphQL schema on a headless CMS. I'm using gatsby-source-graphql on a Gatsby site to get data from it.
There is a content field MyType_BlogPost.body of type String. This contains markdown code.
Is it possible to transform (with gatsby-transformer-remark) that into MarkdownRemark (or similar) so that it will automatically get subfields like html that contain the data one would expect (html code transformed from the markdown source)? I suspect subfields would be the way to do this, but I'm not 100 % of that.
I also suspect this could help but I'm not sure: https://www.gatsbyjs.org/docs/schema-customization/
Thank you.
If the field contains markdown code which you would like to transform into html, you should be able to do that using remark.
Remark is the library that gatsby-transformer-remark uses under the hood.
https://remark.js.org/
Specifically, look at the API section in their docs.

Using the content of an HTML file in a JSON string in shell or Makefile (AWS)

I am attempting to use the AWS apigateway CLI to set an Integration Response mapping template for one of my endpoints in my API. This particular case involves using text/html as my Content-Type and as such my mapping template is raw HTML code. Depending on certain circumstances, I would like to use the CLI to set the mapping template to different HTML code. As such, I am attempting to read the HTML content from a specified file into the --response-template JSON string, which will fill in the mapping template.
The command to do this is as follows:
aws apigateway put-integration-response
--rest-api-id $(restApiId) --resource-id $(resourceId) \
--http-method POST --status-code 200 \
--selection-pattern "" \
--response-parameters '{"method.response.header.Content-Type":"'"'"'text/html'"'"'"}' \
--response-templates '{"text/html": "<!DOCTYPE html><html lang="en"><body><p>Hello, world</p></body></html>"}'
I was originally attempting to do this in a Makefile, hence the variables, but I am open to creating a shell script to achieve the same thing. My HTML file is much larger than the example above and contains scripts with functions, brackets, JSON objects, plenty of strings to stylesheets and whatnot - in other words, many characters that need to be escaped. I cannot manually change the HTML file nor am I sure if I can modify it with escape characters since the mapping template needs to be the exact HTML content as that is what is being rendered.
Is it possible for me to place the entire contents of an HTML file into the value portion of that JSON string? If so, how can I get this to work?
Any help is appreciated.
Simon offered a possible solution to this while using the AWS CLI approach but I have solved this in another way.
I decided to use a Python script with the AWS Python SDK, Boto3. I used Python's json library to dump the content of the HTML file into valid JSON format using json.dumps(). I put that as the value to the JSON object that eventually was used in the Boto3 function below and did an inline replacement of the value as I sent it with json.loads(). I followed the top answer from this link on how to convert html source code to json object.
I used the Boto3 put_integration_response() function and sent that JSON object as the --response-template, which worked for me.

ApiBlueprints parameter that yield result like Stripe's errors "attributes"?

I'm new to Stripe and I'd like generate a result that looks like the "Attributes" part of the Errors part : https://stripe.com/docs/api/curl#errors
It's looks like a table with two column, even though it's not a table.
I don't know how I can make this.
For information, I'm using Aglio to generate the template.
Cyril,
There is no easy way to do this in Markdown that I know of. You have two options:
Create your own layout template that manually adds this information, then tell aglio to use it.
Include some basic HTML in your API Blueprint. Here is an example. It just creates a definition list which describes the error attributes using the same CSS that already exists on the page to describe URI parameters.
You can use Markdown to create the tables of response types and codes, and if you want to use a three-column layout you can use the middle and right CSS classes.
Hope this helps!

filtering kml in a static map

i'm developing a desktop application, not web.
The software environment is Windows and VB10.
In my user interface I have a browser where I want to show a map, issuing an address like http://maps.google.com/maps?q= and then I indicate a URL where I have put a KML file with my data.
The problem is: is it possible to filter the data in the KML file in order to show only a subset of them ?
Basically you have two options:
Pass parameters to a service which generates your filtered KML on the fly.
Do it in JavaScript in your browser interface.
Based on your question, I am going to assume option one is out. For option two there are tons of examples on the web, but basically you need to parse the KML yourself and write JavaScript code to handle it however it needs to be done to achieve your filtering, you cannot pass the KML URL to google maps directly and achieve any of this behaviour.
Possibly useful example: http://www.gpsvisualizer.com/examples/google_folders.html
UPDATE
Based on conversation in the comments:
The only other thing I can think of is to create your own map page with the JavaScript to do what you want on it (like http://gpsvisualizer.com/examples/google_folders.html linked above) and then embedding it in your app instead of the google map. Essentially encapsulating the features you want. So instead of maps.google.com/maps?q= in your app you have myMapURL.com/MyMap?querystring which is your google maps wrapper with the desired filtering. Otherwise I think you are out of luck based on your current setup.

Resources