Comments (7)
Ok, cool, if that resonates, then I'll go with that, along with disabling dash-conversion in the standard markdown conversion.
from notion-py.
I'm having issues with this while trying to upload yaml documents of the format
title: Test
tags:
- Video Game Art
- Blender
- Modelling
- Render
- Cycles
- Quackventures
permalink: test
id: 59f834a1fe4ed100192567da
updated: '2018-06-14T07:20:33.000Z'
date: 2016-02-08 03:59:20
cause issues. The yaml array gets parsed as Markdown and each line becomes separated by a new line and loses the array prefix -
from notion-py.
After further investigation, you can monkey-patch markdown=False
with
from notion.block import CodeBlock
from notion.maps import property_map
CodeBlock.title = property_map('title', markdown=False)
but the problem is the CodeBlock
actually supports Markdown in it (?!). So you'll get CodeBlock
's from the backend looking like
[['titl'], ['e: Bobskater mmmmA Pytho', [['b']]], ['n obfuscation Library\ntags:\nmmmm'], ['Python\nmmmmpython3\nmmmmbobskater\nmmmmobfuscatio', [['s']]], ['n\nmmm'], ['mminify\nmmmmast\nmmmmabs', [['h', 'red']]], ["tract syntax tree\nmmmmregex\npermalink: bobskater-a-python-obfuscation-library\nid: 5adfe539190df80022801a50\nupdated: '2018-08-30T01:31:57.000Z'\ndate: 2018-05-04 21:11:00"]]
If you need a quick and dirty fix and don't need to support Markdown in your code blocks. Use the above monkey patch and then make sure whenever you set title
on a CodeBlock, you're actually passing in [["your code here"]]
to satisfy Notion.so's format
from notion-py.
Good catch! It actually looks as if this isn't something specific to CodeBlock
, as the same thing happens with a basic block when multiple lines prefixed with -
are set. It's just less common outside of a CodeBlock. It seems to be a problem with the way I'm doing "Markdown to Notion" conversion. Or rather, I think it may just be an inherently tricky/ambiguous case, where it doesn't have a good way to tell, when going from Markdown to Notion format, when to interpret literally and when to interpret as Markdown annotations.
the problem is the CodeBlock actually supports Markdown in it (?!)
Exactly. This would all be much easier if we could assume there's no styling within a code block. But as you've observed, in Notion you can select text within a code block and, for example, make it bold.
I'm thinking to add a parallel title_plaintext
property that strips (and adds) the [[ ]]
, but doesn't do any markdown conversion. I'll do a quick pass on that now, but let me know if you have any other suggestions.
from notion-py.
After playing with this a bit more, a couple of observations:
- The same problem happens with other types of Markdown in CodeBlocks (e.g.
__stuff_like_this__
triggers bolding). This doesn't cause issues in the same way for other block types because they automatically convert__X__
and*X*
on the fly into formatting as you type. This auto-styling doesn't happen in CodeBlocks. - I can't actually think of a case where dashes can be used for bullets within Notion (other than as a keyboard shortcut for converting the entire block into a
BulletedListBlock
). So there's no reason we should be touching dashes in the conversion process.
So... if it weren't for 1), then fixing 2) by ignoring dashes would be enough. I'm thinking to ignore dashes, but also just turn off markdown conversion completely for CodeBlock as suggested. This means that modifying an existing CodeBlock that had formatting internally will clear the formatting, but this seems like an uncommon scenario.
from notion-py.
I really like the idea of title_plaintext
. It preserves the current API and gives the user the ability to choose which one to use. Kind of like .innerHTML
and .textContent
in a way...
from notion-py.
Ok, done! Will be in the upcoming release: #84
from notion-py.
Related Issues (20)
- HTTPERROR using children.add_new
- collection.add_row() fails on new databases HOT 2
- How to set database column calculation?
- Not documented: how to set the size of an image HOT 1
- > this is a pretty paralyzing issue. does anyone know how long it will take for it to get merged in? HOT 1
- Uploading image doesn't work HOT 2
- Need to cut a new release
- Notion crashes when setting CollectionView filter with no id HOT 2
- Is this module still work now? I got an error, outdated? HOT 1
- Failed To Run "setup.py" Due To Encoding Error
- requests.exceptions.HTTPError: Invalid input from client.get_block HOT 8
- Unsaved transactions: SpaceShardRecordPointer have no space id HOT 1
- raise InvalidNotionIdentifier(input_value)
- Help!!! requests.exceptions.HTTPError: Invalid input. HOT 4
- TypeError: Retry.__init__() got an unexpected keyword argument 'method_whitelist' HOT 3
- Client POST generates a HTTPError HOT 1
- (question) is there `get_all_comments`? HOT 1
- notion_client.errors.RequestTimeoutError: Request to Notion API has timed out
- HTTPError (400) when trying to load a database despite trying proposed solutions HOT 3
- Search (and find best matching page titles)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from notion-py.