Properly handle metadata tags on auto-postings
This commit is contained in:
parent
484e54c2b3
commit
63712728e1
2 changed files with 22 additions and 7 deletions
|
|
@ -575,7 +575,7 @@ void instance_t::automated_xact_directive(char * line)
|
|||
item = ae.get();
|
||||
|
||||
// This is a trailing note, and possibly a metadata info tag
|
||||
item->append_note(p + 1, *context.scope, true);
|
||||
ae->append_note(p + 1, *context.scope, true);
|
||||
item->add_flags(ITEM_NOTE_ON_NEXT_LINE);
|
||||
item->pos->end_pos = context.curr_pos;
|
||||
item->pos->end_line++;
|
||||
|
|
|
|||
27
src/xact.cc
27
src/xact.cc
|
|
@ -645,6 +645,18 @@ namespace {
|
|||
}
|
||||
}
|
||||
|
||||
static string apply_format(const string& str, scope_t& scope)
|
||||
{
|
||||
if (contains(str, "%(")) {
|
||||
format_t str_format(str);
|
||||
std::ostringstream buf;
|
||||
buf << str_format(scope);
|
||||
return buf.str();
|
||||
} else {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context)
|
||||
{
|
||||
posts_list initial_posts(xact.posts.begin(), xact.posts.end());
|
||||
|
|
@ -696,8 +708,9 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context)
|
|||
if (deferred_notes) {
|
||||
foreach (deferred_tag_data_t& data, *deferred_notes) {
|
||||
if (data.apply_to_post == NULL)
|
||||
initial_post->parse_tags(data.tag_data.c_str(), bound_scope,
|
||||
data.overwrite_existing);
|
||||
initial_post->append_note(
|
||||
apply_format(data.tag_data, bound_scope).c_str(),
|
||||
bound_scope, data.overwrite_existing);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -776,7 +789,7 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context)
|
|||
account = account->parent;
|
||||
account = account->find_account(fullname);
|
||||
}
|
||||
else if (contains(fullname, "%")) {
|
||||
else if (contains(fullname, "%(")) {
|
||||
format_t account_name(fullname);
|
||||
std::ostringstream buf;
|
||||
buf << account_name(bound_scope);
|
||||
|
|
@ -804,9 +817,11 @@ void auto_xact_t::extend_xact(xact_base_t& xact, parse_context_t& context)
|
|||
|
||||
if (deferred_notes) {
|
||||
foreach (deferred_tag_data_t& data, *deferred_notes) {
|
||||
if (! data.apply_to_post || data.apply_to_post == post)
|
||||
new_post->parse_tags(data.tag_data.c_str(), bound_scope,
|
||||
data.overwrite_existing);
|
||||
if (! data.apply_to_post || data.apply_to_post == post) {
|
||||
new_post->append_note(
|
||||
apply_format(data.tag_data, bound_scope).c_str(),
|
||||
bound_scope, data.overwrite_existing);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue