Code Monkey home page Code Monkey logo

Comments (4)

dwrolvink avatar dwrolvink commented on May 25, 2024 1

@jcolson see #46 a config yaml change is needed then this change should fix this issue

from obsidian-html.

dwrolvink avatar dwrolvink commented on May 25, 2024

@jcolson I just woke up, so I won't be working on this for a few hours, might start on it today still if you don't have a go at it.

Code of interest:

def ConvertMarkdownPageToHtmlPage(page_path_str, pb, backlinkNode=None):

# Graph view integrations
# ------------------------------------------------------------------
# The nodelist will result in graph.json, which may have uses beyond the graph view
# [17] Add self to nodelist
node = pb.network_tree.NewNode()
# Use filename as node id, unless 'graph_name' is set in the yaml frontmatter
node['id'] = str(md.rel_dst_path).split('/')[-1].replace('.md', '')
if 'graph_name' in md.metadata.keys():
node['id'] = md.metadata['graph_name']
# Url is used so you can open the note/node by clicking on it
node['url'] = f'{config["html_url_prefix"]}/{str(md.rel_dst_path)[:-3]}.html'
pb.network_tree.AddNode(node)
# Backlinks are set so when recursing, the links (edges) can be determined
if backlinkNode is not None:
link = pb.network_tree.NewLink()
link['source'] = backlinkNode['id']
link['target'] = node['id']
pb.network_tree.AddLink(link)
backlinkNode = node

What needs to be done, imo, is to move the link creation to this loop:

for l in md.links:

But that entails (re)creating a function or something to validate each link before adding a graph link.
Perhaps just seeing if the link ends in .md, but you've seen already how that kind of simple testing can be a breeding ground for bugs.

Don't worry about adding links/nodes twice, this is fenced here:

def AddNode(self, node_obj):
if self.conf['toggles']['verbose_printout']:
print("Received node", node_obj)
# Skip if already present
for node in self.tree['nodes']:
if node['id'] == node_obj['id']:
if self.conf['toggles']['verbose_printout']:
print("Node already present")
return
# Add node
self.tree['nodes'].append(node_obj)
if self.conf['toggles']['verbose_printout']:
print("Node added")
def AddLink(self, link_obj):
if self.conf['toggles']['verbose_printout']:
print("Received link", link_obj)
# Skip if already present
for link in self.tree['links']:
if link['source'] == link_obj['source'] and link['target'] == link_obj['target']:
if self.conf['toggles']['verbose_printout']:
print("Link already present")
return
# Add link
self.tree['links'].append(link_obj)
if self.conf['toggles']['verbose_printout']:
print("Link added")

from obsidian-html.

dwrolvink avatar dwrolvink commented on May 25, 2024

working on this

from obsidian-html.

jcolson avatar jcolson commented on May 25, 2024

works like a champ! lovely!

from obsidian-html.

Related Issues (20)

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.